[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31051] branches/soc-2010-jwilkins: == Adjustable Angle for Front-Face Only ==
Jason Wilkins
Jason.A.Wilkins at gmail.com
Wed Aug 4 21:35:28 CEST 2010
Revision: 31051
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31051
Author: jwilkins
Date: 2010-08-04 21:35:27 +0200 (Wed, 04 Aug 2010)
Log Message:
-----------
== Adjustable Angle for Front-Face Only ==
* Fix: trim is now a lot smoother
* Fix: space stroke regressed due to changes for adaptive spacing
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/blenloader/intern/readfile.c
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.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-04 19:32:37 UTC (rev 31050)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-08-04 19:35:27 UTC (rev 31051)
@@ -643,7 +643,10 @@
col.separator()
row= col.row()
- row.prop(brush, "use_frontface", text="Front Faces Only")
+ row.prop(brush, "use_frontface", text="Front-Faces Only")
+ row= col.row()
+ row.active = brush.use_frontface
+ row.prop(brush, "frontface_angle", text="Angle")
col.separator()
col.row().prop(brush, "direction", expand=True)
Modified: branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c 2010-08-04 19:32:37 UTC (rev 31050)
+++ branches/soc-2010-jwilkins/source/blender/blenkernel/intern/brush.c 2010-08-04 19:35:27 UTC (rev 31051)
@@ -98,6 +98,8 @@
brush->adaptive_space_factor= 1;
+ brush->frontface_angle= 80;
+
/* BRUSH TEXTURE SETTINGS */
default_mtex(&brush->mtex);
Modified: branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c 2010-08-04 19:32:37 UTC (rev 31050)
+++ branches/soc-2010-jwilkins/source/blender/blenloader/intern/readfile.c 2010-08-04 19:35:27 UTC (rev 31051)
@@ -11055,6 +11055,9 @@
if (brush->sculpt_plane_range == 0)
brush->sculpt_plane_range= 1;
+ if (brush->frontface_angle== 0)
+ brush->frontface_angle= (float)(M_PI_2 * 80.0/90.0);
+
/* 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/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-08-04 19:32:37 UTC (rev 31050)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-08-04 19:35:27 UTC (rev 31051)
@@ -1624,6 +1624,7 @@
if (stroke->brush->flag & BRUSH_ADAPTIVE_SPACE) {
float t= 0;
+
for(;;) {
float f;
float d;
@@ -1649,18 +1650,16 @@
else {
int i, steps;
- steps = 1 / scale;
+ copy_v2_v2(mouse, start_mouse);
+ mul_v2_fl(vec, scale);
- for (i= 0; i < steps; i++) {
- mul_v2_v2fl(dvec, vec, (float)i/(float)steps);
- add_v2_v2v2(mouse, start_mouse, dvec);
+ steps = (int)(1.0f / scale);
+ for(i = 0; i < steps; ++i, ++cnt) {
+ add_v2_v2(mouse, vec);
paint_brush_stroke_add_step(C, op, event, mouse);
-
- cnt++;
}
}
-
}
}
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-04 19:32:37 UTC (rev 31050)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-08-04 19:35:27 UTC (rev 31051)
@@ -248,6 +248,8 @@
int alt_smooth;
float plane_trim_squared;
+
+ float frontface_start, frontface_range;
} StrokeCache;
/* rotation direction is flipped in different symmetrical passes */
@@ -442,26 +444,24 @@
}
}
-static float frontface(Brush *brush, float sculpt_normal[3], short no[3], float fno[3])
+static float frontface(Brush *brush, float start, float range, float sculpt_normal[3], short no[3])
{
if (brush->flag & BRUSH_FRONTFACE) {
- float dot;
+ float angle;
+ float tmp[3];
- if (no) {
- float tmp[3];
+ normal_short_to_float_v3(tmp, no);
+ angle= angle_normalized_v3v3(tmp, sculpt_normal);
- normal_short_to_float_v3(tmp, no);
- dot= dot_v3v3(tmp, sculpt_normal);
+ if (angle >= start+range) {
+ return 0;
}
- else {
- dot= dot_v3v3(fno, sculpt_normal);
+ else if (angle > start) {
+ return (start+range-angle) / range;
}
+ }
- return dot > 0 ? dot : 0;
- }
- else {
- return 1;
- }
+ return 1;
}
static void set_adaptive_space_factor(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float an_in[3])
@@ -1183,8 +1183,14 @@
sculpt_brush_test_init(ss, &test);
BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
+ short (*origno)[3];
+ SculptUndoNode *unode;
+
+ unode= sculpt_undo_push_node(ss, node);
+ origno= unode->no;
+
if(sculpt_brush_test(&test, vd.co)) {
- const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->view_normal, vd.no, vd.fno);
+ const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, ss->cache->view_normal, origno[vd.i]);
float avg[3], val[3];
neighbor_average(ss, avg, vd.vert_indices[vd.i]);
@@ -1210,8 +1216,14 @@
DMGridAdjacency *gridadj, *adj;
float (*tmpgrid)[3], (*tmprow)[3];
int v1, v2, v3, v4;
- int *grid_indices, totgrid, gridsize, i, x, y;
+ int *grid_indices, totgrid, gridsize, i, k, x, y;
+ short (*origno)[3];
+ SculptUndoNode *unode;
+
+ unode= sculpt_undo_push_node(ss, node);
+ origno= unode->no;
+
sculpt_brush_test_init(ss, &test);
CLAMP(bstrength, 0.0f, 1.0f);
@@ -1225,7 +1237,7 @@
tmprow= MEM_mallocN(sizeof(float)*3*gridsize, "tmprow");
}
- for(i = 0; i < totgrid; ++i) {
+ for(i = 0, k= 0; i < totgrid; ++i) {
data = griddata[grid_indices[i]];
adj = &gridadj[grid_indices[i]];
@@ -1254,8 +1266,8 @@
}
/* blend with existing coordinates */
- for(y = 0; y < gridsize; ++y) {
- for(x = 0; x < gridsize; ++x) {
+ for(y= 0; y < gridsize; ++y) {
+ for(x= 0; x < gridsize; ++x, ++k) {
float *co;
float *fno;
int index;
@@ -1277,7 +1289,7 @@
fno= data[index].no;
if(sculpt_brush_test(&test, co)) {
- const float fade = bstrength*tex_strength(ss, brush, co, test.dist)*frontface(brush, ss->cache->view_normal, NULL, fno);
+ const float fade = bstrength*tex_strength(ss, brush, co, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, ss->cache->view_normal, origno[k]);
float *avg, val[3];
float n;
@@ -1373,7 +1385,12 @@
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
+ short (*origno)[3];
+ SculptUndoNode *unode;
+ unode= sculpt_undo_push_node(ss, nodes[n]);
+ origno= unode->no;
+
proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -1382,7 +1399,7 @@
if (sculpt_brush_test(&test, vd.co)) {
//if(sculpt_brush_test_cyl(&test, vd.co, ss->cache->location, an)) {
/* offset vertex */
- float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, an, vd.no, vd.fno);
+ float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, an, origno[vd.i]);
mul_v3_v3fl(proxy[vd.i], offset, fade);
@@ -1431,7 +1448,12 @@
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
+ short (*origno)[3];
+ SculptUndoNode *unode;
+ unode= sculpt_undo_push_node(ss, nodes[n]);
+ origno= unode->no;
+
proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
sculpt_brush_test_init(ss, &test);
@@ -1439,7 +1461,7 @@
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if(sculpt_brush_test(&test, vd.co)) {
/* offset vertex */
- const float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, an, vd.no, vd.fno);
+ const float fade = tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_start, an, origno[vd.i]);
float val1[3];
float val2[3];
@@ -1476,14 +1498,19 @@
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
+ short (*origno)[3];
+ SculptUndoNode *unode;
+ unode= sculpt_undo_push_node(ss, nodes[n]);
+ origno= unode->no;
+
proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
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)) {
- float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->view_normal, vd.no, vd.fno);
+ float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, ss->cache->view_normal, origno[vd.i]);
float val[3];
sub_v3_v3v3(val, test.location, vd.co);
@@ -1541,7 +1568,7 @@
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if(sculpt_brush_test(&test, origco[vd.i])) {
- const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist)*frontface(brush, an, origno[vd.i], NULL);
+ const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, an, origno[vd.i]);
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
@@ -1578,14 +1605,19 @@
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
+ short (*origno)[3];
+ SculptUndoNode *unode;
+ unode= sculpt_undo_push_node(ss, nodes[n]);
+ origno= unode->no;
+
proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
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*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, an, vd.no, vd.fno);
+ const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist)*frontface(brush, ss->cache->frontface_start, ss->cache->frontface_range, an, origno[vd.i]);
mul_v3_v3fl(proxy[vd.i], cono, fade);
@@ -1630,14 +1662,19 @@
PBVHVertexIter vd;
SculptBrushTest test;
float (*proxy)[3];
+ short (*origno)[3];
+ SculptUndoNode *unode;
+ unode= sculpt_undo_push_node(ss, nodes[n]);
+ origno= unode->no;
+
proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list