[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30122] branches/soc-2010-jwilkins: * enabled jitter for position in sculpt mode
Jason Wilkins
Jason.A.Wilkins at gmail.com
Thu Jul 8 18:51:06 CEST 2010
Revision: 30122
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30122
Author: jwilkins
Date: 2010-07-08 18:51:06 +0200 (Thu, 08 Jul 2010)
Log Message:
-----------
* enabled jitter for position in sculpt mode
Modified Paths:
--------------
branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt_intern.h
Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-07-08 16:24:24 UTC (rev 30121)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-07-08 16:51:06 UTC (rev 30122)
@@ -601,15 +601,6 @@
row = col.row()
row.prop(brush, "strength_multiplier")
-
-
- # XXX - TODO
- #col.separator()
- #row = col.row(align=True)
- #row.prop(brush, "jitter", slider=True)
- #row.prop(brush, "use_jitter_pressure", toggle=True, text="")
-
-
if brush.sculpt_tool not in ('SMOOTH'):
col.separator()
@@ -927,6 +918,13 @@
sub.active = brush.use_smooth_stroke
sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
+
+ col.separator()
+
+ row = col.row(align=True)
+ row.prop(brush, "jitter", slider=True)
+ row.prop(brush, "use_jitter_pressure", toggle=True, text="")
+
else:
row = col.row()
row.prop(brush, "use_airbrush")
Modified: branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c 2010-07-08 16:24:24 UTC (rev 30121)
+++ branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c 2010-07-08 16:51:06 UTC (rev 30122)
@@ -761,12 +761,12 @@
brush->spacing = MAX2(1.0, painter->startspacing*(1.5f-pressure));
}
-static void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos)
+void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos)
{
if(brush->jitter){
float rand_pos[2];
- // find random position within a unit circle
+ // find random position within a circle of diameter 1
do {
rand_pos[0] = BLI_frand()-0.5f;
rand_pos[1] = BLI_frand()-0.5f;
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-07-08 16:24:24 UTC (rev 30121)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-07-08 16:51:06 UTC (rev 30122)
@@ -875,8 +875,13 @@
}
/* Put the location of the next stroke dot into the stroke RNA and apply it to the mesh */
-static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse[2])
+static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *event, float mouse_in[2])
{
+ Paint *paint = paint_get_active(CTX_data_scene(C)); // XXX
+ Brush *brush = paint_brush(paint); // XXX
+
+ float mouse[2];
+
PointerRNA itemptr;
float location[3];
@@ -884,13 +889,11 @@
float pressure;
int pen_flip;
+ ViewContext vc; // XXX
+
PaintStroke *stroke = op->customdata;
- /* XXX: can remove the if statement once all modes have this */
- if(stroke->get_location)
- stroke->get_location(C, stroke, location, mouse);
- else
- zero_v3(location);
+ view3d_set_viewcontext(C, &vc); // XXX
/* Tablet */
if(event->custom == EVT_DATA_TABLET) {
@@ -904,6 +907,28 @@
pen_flip = 0;
}
+ // XXX: temporary check for sculpt mode until things are more unified
+ if (vc.obact->sculpt) {
+ float delta[3];
+
+ brush_jitter_pos(brush, mouse_in, mouse);
+
+ // XXX: meh, this is round about because brush_jitter_pos isn't written in the best way to be reused here
+ if (brush->flag & BRUSH_JITTER_PRESSURE) {
+ sub_v3_v3v3(delta, mouse, mouse_in);
+ mul_v3_fl(delta, pressure);
+ add_v3_v3v3(mouse, mouse_in, delta);
+ }
+ }
+ else
+ copy_v3_v3(mouse, mouse_in);
+
+ /* XXX: can remove the if statement once all modes have this */
+ if(stroke->get_location)
+ stroke->get_location(C, stroke, location, mouse);
+ else
+ zero_v3(location);
+
/* Add to stroke */
RNA_collection_add(op->ptr, "stroke", &itemptr);
@@ -988,6 +1013,7 @@
for(i = 0; i < steps; ++i, ++cnt) {
add_v2_v2(mouse, vec);
+ printf("3\n");
paint_brush_stroke_add_step(C, op, event, mouse);
}
}
@@ -1067,8 +1093,10 @@
//ED_region_tag_redraw(ar);
}
}
- else
+ else {
+ printf("1\n");
paint_brush_stroke_add_step(C, op, event, mouse);
+ }
}
else
;//ED_region_tag_redraw(ar);
@@ -1082,6 +1110,7 @@
!(stroke->brush->flag & BRUSH_ANCHORED) &&
!(stroke->brush->flag & BRUSH_SMOOTH_STROKE))
{
+ printf("2\n");
paint_brush_stroke_add_step(C, op, event, mouse);
}
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt_intern.h
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt_intern.h 2010-07-08 16:24:24 UTC (rev 30121)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt_intern.h 2010-07-08 16:51:06 UTC (rev 30122)
@@ -110,4 +110,6 @@
int sculpt_modifiers_active(Scene *scene, Object *ob);
void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]);
+void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos);
+
#endif
More information about the Bf-blender-cvs
mailing list