[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29045] branches/soc-2010-jwilkins: * disabled openmp for now
Jason Wilkins
Jason.A.Wilkins at gmail.com
Fri May 28 12:37:16 CEST 2010
Revision: 29045
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29045
Author: jwilkins
Date: 2010-05-28 12:37:15 +0200 (Fri, 28 May 2010)
Log Message:
-----------
* disabled openmp for now
* created a function calc_area_normal_and_flatten_center to get rid of the loop over head of calculating them seperately
* changed stroke spacing to be a percentage of brush size instead of absolute pixels
* UI for stroke spacing now goes from 1-500 percent
* the power of overlapping strokes is attenuated by one minus of the amount of circle overlap
* tweaked clay brush strength upwards to account for attenuation
* clay now obey's the accumulate checkbox
Modified Paths:
--------------
branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
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/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-05-28 07:18:11 UTC (rev 29044)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-05-28 10:37:15 UTC (rev 29045)
@@ -566,7 +566,7 @@
if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
col.row().prop(brush, "direction", expand=True)
- if brush.sculpt_tool in ('DRAW', 'INFLATE', 'LAYER'):
+ if brush.sculpt_tool in ('DRAW', 'INFLATE', 'LAYER', 'CLAY'):
col.prop(brush, "use_accumulate")
if brush.sculpt_tool == 'LAYER':
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-05-28 07:18:11 UTC (rev 29044)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-05-28 10:37:15 UTC (rev 29045)
@@ -183,33 +183,36 @@
towards the final mouse location. */
static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const float final_mouse[2])
{
- PaintStroke *stroke = op->customdata;
- int cnt = 0;
+ PaintStroke *stroke = op->customdata;
+ int cnt = 0;
- if(paint_space_stroke_enabled(stroke->brush)) {
- float mouse[2] = {stroke->last_mouse_position[0], stroke->last_mouse_position[1]};
- float vec[2] = {final_mouse[0] - mouse[0], final_mouse[1] - mouse[1]};
- float length, scale;
- int steps = 0, i;
+ if(paint_space_stroke_enabled(stroke->brush)) {
+ float mouse[2];
+ float vec[2];
+ float length, scale;
- /* Normalize the vector between the last stroke dot and the goal */
- length = sqrt(vec[0]*vec[0] + vec[1]*vec[1]);
+ copy_v2_v2(mouse, stroke->last_mouse_position);
+ sub_v2_v2v2(vec, final_mouse, mouse);
- if(length > FLT_EPSILON) {
- scale = stroke->brush->spacing / length;
- vec[0] *= scale;
- vec[1] *= scale;
+ length = len_v2(vec);
- steps = (int)(length / stroke->brush->spacing);
- for(i = 0; i < steps; ++i, ++cnt) {
- mouse[0] += vec[0];
- mouse[1] += vec[1];
- paint_brush_stroke_add_step(C, op, event, mouse);
- }
- }
- }
+ if(length > FLT_EPSILON) {
+ int steps;
+ int i;
- return cnt;
+ scale = (stroke->brush->size*stroke->brush->spacing/100.0f) / length;
+ mul_v2_fl(vec, scale);
+
+ 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);
+ }
+ }
+ }
+
+ return cnt;
}
/**** Public API ****/
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-05-28 07:18:11 UTC (rev 29044)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-05-28 10:37:15 UTC (rev 29045)
@@ -568,6 +568,19 @@
return distsq < test->radius_squared;
}
+/* area of overlap of two circles of radius 1 seperated by d units from their centers */
+static float circle_overlap(float d)
+{
+ return (2*acos(d/2)-(1/2)*d*sqrt(4-d*d));
+}
+
+/* percentage of overlap of two circles of radius 1 seperated by d units from their centers */
+/* TODO: cache one minus this value*/
+static float circle_overlap_percent(float d)
+{
+ return circle_overlap(d) / M_PI;
+}
+
/* ===== Sculpting =====
*
*/
@@ -583,16 +596,17 @@
float alpha = brush->alpha * brush->alpha;
float dir = brush->flag & BRUSH_DIR_IN ? -1 : 1;
- float pressure = 1;
- float flip = cache->flip ? -1:1;
+ float pressure = brush->flag & BRUSH_ALPHA_PRESSURE ? cache->pressure : 1;
+ float flip = cache->flip ? -1 : 1;
+ float overlap = brush->spacing < 100.0f ? 1 - circle_overlap_percent(brush->spacing/50.0f) : 1; // spacing is integer percentage of radius, divide by 50 to get normalized diameter
- if(brush->flag & BRUSH_ALPHA_PRESSURE) pressure *= cache->pressure;
-
switch(brush->sculpt_tool){
case SCULPT_TOOL_DRAW:
case SCULPT_TOOL_INFLATE:
+ return alpha * dir * pressure * flip * overlap;
+
case SCULPT_TOOL_CLAY:
- return alpha * dir * pressure * flip;
+ return alpha / 2 * dir * pressure * flip * overlap;
case SCULPT_TOOL_FLATTEN:
case SCULPT_TOOL_LAYER:
@@ -820,8 +834,8 @@
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
- //SculptUndoNode *unode;
- float fno[3];
+
+ float fno[3];
float nout[3] = {0.0f, 0.0f, 0.0f};
float nout_flip[3] = {0.0f, 0.0f, 0.0f};
@@ -877,7 +891,7 @@
offset[2]= area_normal[2]*ss->cache->radius*ss->cache->scale[2]*bstrength;
/* threaded loop over nodes */
- #pragma omp parallel for private(n) schedule(static)
+ //#pragma omp parallel for private(n) schedule(static)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -991,7 +1005,7 @@
BLI_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid,
NULL, &gridsize, &griddata, &gridadj);
- #pragma omp critical
+ //#pragma omp critical
tmpgrid= MEM_mallocN(sizeof(float)*3*gridsize*gridsize, "tmpgrid");
for(i = 0; i < totgrid; ++i) {
@@ -1050,7 +1064,7 @@
}
}
- #pragma omp critical
+ //#pragma omp critical
MEM_freeN(tmpgrid);
}
@@ -1059,7 +1073,7 @@
int iteration, n;
for(iteration = 0; iteration < 2; ++iteration) {
- #pragma omp parallel for private(n) schedule(static)
+ //#pragma omp parallel for private(n) schedule(static)
for(n=0; n<totnode; n++) {
sculpt_undo_push_node(ss, nodes[n]);
@@ -1082,7 +1096,7 @@
float bstrength= ss->cache->bstrength;
int n;
- #pragma omp parallel for private(n) schedule(static)
+ //#pragma omp parallel for private(n) schedule(static)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1116,7 +1130,7 @@
copy_v3_v3(grab_delta, ss->cache->grab_delta_symmetry);
- #pragma omp parallel for private(n) schedule(static)
+ //#pragma omp parallel for private(n) schedule(static)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1159,7 +1173,7 @@
offset[1]= ss->cache->scale[1]*area_normal[1];
offset[2]= ss->cache->scale[2]*area_normal[2];
- #pragma omp parallel for private(n) schedule(static)
+ //#pragma omp parallel for private(n) schedule(static)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1216,7 +1230,7 @@
float bstrength= ss->cache->bstrength;
int n;
- #pragma omp parallel for private(n) schedule(static)
+ //#pragma omp parallel for private(n) schedule(static)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1248,98 +1262,61 @@
}
}
-//static void calc_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float co[3])
-//{
-// float outer_dist[FLATTEN_SAMPLE_SIZE];
-// float outer_co[FLATTEN_SAMPLE_SIZE][3];
-//
-// int n;
-//
-// float count;
-//
-// for (n = 0; n < FLATTEN_SAMPLE_SIZE; n++) {
-// zero_v3(outer_co[n]);
-// outer_dist[n]= -1.0f;
-// }
-//
-// for (n = 0; n < totnode; n++) {
-// PBVHVertexIter vd;
-// SculptBrushTest test;
-//
-// int j;
-//
-// //sculpt_undo_push_node(ss, nodes[n]);
-//
-// 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)) {
-// for (j = 0; j < FLATTEN_SAMPLE_SIZE; ++j) {
-// if (test.dist > outer_dist[j]) {
-// copy_v3_v3(outer_co[j], vd.co);
-// outer_dist[j] = test.dist;
-// break;
-// }
-// }
-// }
-// }
-// BLI_pbvh_vertex_iter_end;
-//
-// //BLI_pbvh_node_mark_update(nodes[n]);
-// }
-//
-// count = co[0] = co[1] = co[2] = 0.0f;
-//
-// for (n = 0; n < FLATTEN_SAMPLE_SIZE; n++) {
-// if (outer_dist[n] >= 0.0f) {
-// add_v3_v3(co, outer_co[n]);
-// count++;
-// }
-// }
-//
-// mul_v3_fl(co, 1.0f / count);
-//}
-
-static void calc_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float co[3])
+static void calc_area_normal_and_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float area_normal[3], float center[3])
{
+ // an
+ PBVH *bvh= ss->pbvh;
+ StrokeCache *cache = ss->cache;
+ float out_flip[3] = {0.0f, 0.0f, 0.0f};
int n;
+ // fc
float count = 0;
- co[0] = co[1] = co[2] = 0;
+ // an
+ area_normal[0] = area_normal[1] = area_normal[2] = 0;
- for (n = 0; n < totnode; n++) {
+ // fc
+ center[0] = center[1] = center[2] = 0;
+
+ for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
sculpt_brush_test_init(ss, &test);
- BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
- if (sculpt_brush_test_fast(&test, vd.co)) {
- add_v3_v3(co, vd.co);
+ BLI_pbvh_vertex_iter_begin(bvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+ if(sculpt_brush_test_fast(&test, vd.co)) {
+ // an
+ if(vd.no) {
+ float fno[3];
+
+ normal_short_to_float_v3(fno, vd.no);
+ add_norm_if(cache->view_normal_symmetry, area_normal, out_flip, fno);
+ }
+ else {
+ add_norm_if(cache->view_normal_symmetry, area_normal, out_flip, vd.fno);
+ }
+
+ // fc
+ add_v3_v3(center, vd.co);
count++;
}
}
BLI_pbvh_vertex_iter_end;
}
- mul_v3_fl(co, 1.0f / count);
-}
+ // an
+ if (area_normal[0]==0.0 && area_normal[1]==0.0 && area_normal[2]==0.0) {
+ copy_v3_v3(area_normal, out_flip);
+ }
-///* Projects a point onto a plane along the plane's normal */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list