[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31130] branches/soc-2010-jwilkins: == Layer Modifier Brushes ==
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat Aug 7 03:58:28 CEST 2010
Revision: 31130
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31130
Author: jwilkins
Date: 2010-08-07 03:58:26 +0200 (Sat, 07 Aug 2010)
Log Message:
-----------
== Layer Modifier Brushes ==
For all tools that it makes sense for, the 'Use Layer' modifier allows you to set a limit on how far a vertex moves which creates a layering effect.
Also, added a slider to control how thick a layer is.
Also, Fix #23192, where layers were not working with symmetry.
After testing more will apply to trunk.
Modified Paths:
--------------
branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h
branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-08-07 00:33:53 UTC (rev 31129)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-08-07 01:58:26 UTC (rev 31130)
@@ -664,11 +664,17 @@
col.prop(brush, "use_accumulate")
+ if brush.sculpt_tool not in ('LAYER', 'GRAB', 'ROTATE', 'THUMB', 'SMOOTH'):
+ col.separator()
+ col.prop(brush, "use_layer")
- if brush.sculpt_tool == 'LAYER':
+ if brush.sculpt_tool in ('LAYER'):
col.separator()
+ if brush.sculpt_tool not in ('GRAB', 'ROTATE', 'THUMB', 'SMOOTH'):
+ col.prop(brush, "layer_distance")
+
ob = context.sculpt_object
do_persistent = True
Modified: branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c 2010-08-07 00:33:53 UTC (rev 31129)
+++ branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c 2010-08-07 01:58:26 UTC (rev 31130)
@@ -11058,6 +11058,9 @@
if (brush->frontface_angle== 0)
brush->frontface_angle= (float)(M_PI_2 * 80.0/90.0);
+ if (brush->layer_distance== 0)
+ brush->layer_distance= 0.25f;
+
/* New Settings */
if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) {
brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive strength
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-08-07 00:33:53 UTC (rev 31129)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-08-07 01:58:26 UTC (rev 31130)
@@ -1846,85 +1846,85 @@
}
}
-static void do_layer_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
-{
- Brush *brush = paint_brush(&sd->paint);
- float bstrength= ss->cache->bstrength;
- float an[3], offset[3];
- float lim= ss->cache->radius / 4;
- int n;
+//static void do_layer_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
+//{
+// Brush *brush = paint_brush(&sd->paint);
+// float bstrength= ss->cache->bstrength;
+// float an[3], offset[3];
+// float lim= ss->cache->radius / 4;
+// int n;
+//
+// if(bstrength < 0)
+// lim = -lim;
+//
+// calc_sculpt_normal(sd, ss, an, nodes, totnode, brush->sculpt_plane_range);
+//
+// set_brush_local_mat(sd, ss, brush, NULL, 0, an);
+//
+// set_adaptive_space_factor(sd, ss, NULL, 0, an);
+//
+// mul_v3_v3v3(offset, ss->cache->scale, an);
+//
+// #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
+// for(n=0; n<totnode; n++) {
+// PBVHVertexIter vd;
+// SculptBrushTest test;
+// SculptUndoNode *unode;
+// float (*origco)[3], *layer_disp;
+// //float (*proxy)[3]; // XXX layer brush needs conversion to proxy but its more complicated
+//
+// //proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+//
+// short (*origno)[3];
+//
+// unode= sculpt_undo_push_node(ss, nodes[n]);
+// origco=unode->co;
+// if(!unode->layer_disp)
+// {
+// #pragma omp critical
+// unode->layer_disp= MEM_callocN(sizeof(float)*unode->totvert, "layer disp");
+// }
+//
+// layer_disp= unode->layer_disp;
+//
+// origno= unode->no;
+//
+// sculpt_brush_test_init(ss, &test);
+//
+// BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+// if(sculpt_brush_test(&test, vd.co)) {
+// const float fade = bstrength*ss->cache->radius*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, an, origno[vd.i]);
+// float *disp= &layer_disp[vd.i];
+// float val[3];
+//
+// *disp+= fade;
+//
+// /* Don't let the displacement go past the limit */
+// if((lim < 0 && *disp < lim) || (lim > 0 && *disp > lim))
+// *disp = lim;
+//
+// mul_v3_v3fl(val, offset, *disp);
+//
+// if(ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
+// int index= vd.vert_indices[vd.i];
+//
+// /* persistent base */
+// add_v3_v3(val, ss->layer_co[index]);
+// }
+// else {
+// add_v3_v3(val, origco[vd.i]);
+// }
+//
+// sculpt_clip(sd, ss, vd.co, val);
+//
+// if(vd.mvert)
+// vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+// }
+// }
+// BLI_pbvh_vertex_iter_end;
+// }
+//}
- if(bstrength < 0)
- lim = -lim;
-
- calc_sculpt_normal(sd, ss, an, nodes, totnode, brush->sculpt_plane_range);
-
- set_brush_local_mat(sd, ss, brush, NULL, 0, an);
-
- set_adaptive_space_factor(sd, ss, NULL, 0, an);
-
- mul_v3_v3v3(offset, ss->cache->scale, an);
-
- #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
- for(n=0; n<totnode; n++) {
- PBVHVertexIter vd;
- SculptBrushTest test;
- SculptUndoNode *unode;
- float (*origco)[3], *layer_disp;
- //float (*proxy)[3]; // XXX layer brush needs conversion to proxy but its more complicated
-
- //proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
-
- short (*origno)[3];
-
- unode= sculpt_undo_push_node(ss, nodes[n]);
- origco=unode->co;
- if(!unode->layer_disp)
- {
- #pragma omp critical
- unode->layer_disp= MEM_callocN(sizeof(float)*unode->totvert, "layer disp");
- }
-
- layer_disp= unode->layer_disp;
-
- origno= unode->no;
-
- sculpt_brush_test_init(ss, &test);
-
- BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
- if(sculpt_brush_test(&test, vd.co)) {
- const float fade = bstrength*ss->cache->radius*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, an, origno[vd.i]);
- float *disp= &layer_disp[vd.i];
- float val[3];
-
- *disp+= fade;
-
- /* Don't let the displacement go past the limit */
- if((lim < 0 && *disp < lim) || (lim > 0 && *disp > lim))
- *disp = lim;
-
- mul_v3_v3fl(val, offset, *disp);
-
- if(ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
- int index= vd.vert_indices[vd.i];
-
- /* persistent base */
- add_v3_v3(val, ss->layer_co[index]);
- }
- else {
- add_v3_v3(val, origco[vd.i]);
- }
-
- sculpt_clip(sd, ss, vd.co, val);
-
- if(vd.mvert)
- vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
- }
- }
- BLI_pbvh_vertex_iter_end;
- }
-}
-
static void do_inflate_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
{
Brush *brush = paint_brush(&sd->paint);
@@ -2764,7 +2764,8 @@
do_thumb_brush(sd, ss, nodes, totnode);
break;
case SCULPT_TOOL_LAYER:
- do_layer_brush(sd, ss, nodes, totnode);
+ //do_layer_brush(sd, ss, nodes, totnode);
+ do_draw_brush(sd, ss, nodes, totnode);
break;
case SCULPT_TOOL_FLATTEN:
do_flatten_brush(sd, ss, nodes, totnode);
@@ -2863,6 +2864,7 @@
case SCULPT_TOOL_PINCH:
case SCULPT_TOOL_SCRAPE:
case SCULPT_TOOL_SNAKE_HOOK:
+ case SCULPT_TOOL_LAYER:
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for (n= 0; n < totnode; n++) {
PBVHVertexIter vd;
@@ -2876,10 +2878,34 @@
int p;
copy_v3_v3(val, vd.co);
-
for (p= 0; p < proxy_count; p++)
add_v3_v3(val, proxies[p].co[vd.i]);
+ if (brush->sculpt_tool == SCULPT_TOOL_LAYER || brush->flag & BRUSH_LAYER) {
+ float disp[3];
+ float len;
+ float *base;
+
+ if (ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) {
+ int index= vd.vert_indices[vd.i];
+
+ /* persistent base */
+ base= ss->layer_co[index];
+ }
+ else {
+ base= sculpt_undo_push_node(ss, nodes[n])->co[vd.i];
+ }
+
+ sub_v3_v3v3(disp, val, base);
+ len= len_v3(disp);
+
+ if (len > ss->cache->radius*brush->layer_distance) {
+ normalize_v3(disp);
+ mul_v3_fl(disp, ss->cache->radius*brush->layer_distance);
+ add_v3_v3v3(val, disp, base);
+ }
+ }
+
sculpt_clip(sd, ss, vd.co, val);
}
BLI_pbvh_vertex_iter_end;
@@ -2891,7 +2917,6 @@
break;
case SCULPT_TOOL_SMOOTH:
- case SCULPT_TOOL_LAYER:
default:
break;
}
Modified: branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h 2010-08-07 00:33:53 UTC (rev 31129)
+++ branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h 2010-08-07 01:58:26 UTC (rev 31130)
@@ -92,6 +92,8 @@
float plane_trim;
+ float layer_distance, pad2;
+
float texture_sample_bias;
int texture_overlay_alpha;
@@ -133,6 +135,7 @@
#define BRUSH_FRONTFACE (1<<27)
#define BRUSH_CUSTOM_ICON (1<<28)
#define BRUSH_SYMMETRY_FEATHER (1<<29)
+#define BRUSH_LAYER (1<<30)
/* Brush.sculpt_tool */
#define SCULPT_TOOL_DRAW 1
Modified: branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c 2010-08-07 00:33:53 UTC (rev 31129)
+++ branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c 2010-08-07 01:58:26 UTC (rev 31130)
@@ -628,6 +628,14 @@
RNA_def_property_ui_text(prop, "Front-Face Angle", "Angle where effect of brush starts to be reduced to prevent it affecting back-faces");
RNA_def_property_update(prop, 0, "rna_Brush_update");
+ prop= RNA_def_property(srna, "layer_distance", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "layer_distance");
+ RNA_def_property_float_default(prop, 0);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 0.001);
+ RNA_def_property_ui_text(prop, "Layer Distance", "Limit to how far a vertex can travel in a single stroke as a fraction of brush radius");
+ RNA_def_property_update(prop, 0, "rna_Brush_update");
+
/* flag */
prop= RNA_def_property(srna, "use_airbrush", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);
@@ -707,6 +715,11 @@
RNA_def_property_ui_text(prop, "Symmetry Feathering", "Reduce the strength of the brush where it overlaps symmetrical daubs");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list