[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29586] branches/soc-2010-jwilkins: == Optional OpenMP ==
Jason Wilkins
Jason.A.Wilkins at gmail.com
Mon Jun 21 08:55:18 CEST 2010
Revision: 29586
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29586
Author: jwilkins
Date: 2010-06-21 08:55:18 +0200 (Mon, 21 Jun 2010)
Log Message:
-----------
== Optional OpenMP ==
OpenMP can be re-enabled by checking "Use OpenMP"
Also, area normal and tangent plane are not unnecessarily recalculated for symmetry but are simply flipped.
Modified Paths:
--------------
branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2010-jwilkins/source/blender/makesdna/DNA_scene_types.h
branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_sculpt_paint.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-06-21 05:37:12 UTC (rev 29585)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-06-21 06:55:18 UTC (rev 29586)
@@ -851,6 +851,7 @@
if sculpt.show_brush:
col.prop(sculpt, "show_brush_on_surface")
col.prop(sculpt, "fast_navigate")
+ col.prop(sculpt, "use_openmp")
if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'PINCH'):
sub = col.column()
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-06-21 05:37:12 UTC (rev 29585)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-06-21 06:55:18 UTC (rev 29586)
@@ -91,9 +91,9 @@
#include <stdlib.h>
#include <string.h>
-//#ifdef _OPENMP
-//#include <omp.h>
-//#endif
+#ifdef _OPENMP
+#include <omp.h>
+#endif
void ED_sculpt_force_update(bContext *C)
{
@@ -821,104 +821,112 @@
{
Brush *brush = paint_brush(&sd->paint);
- int n;
+ if (ss->cache->symmetry_pass == 0 &&
+ (ss->cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL)))
+ {
+ int sculpt_direction = (brush->flag & BRUSH_ORIGINAL_NORMAL) ? brush->sculpt_direction : SCULPT_DISP_DIR_AREA;
- float out_flip[3] = {0.0f, 0.0f, 0.0f};
+ switch (sculpt_direction) {
+ case SCULPT_DISP_DIR_VIEW:
+ viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
+ break;
- zero_v3(an);
+ case SCULPT_DISP_DIR_X:
+ an[1] = 0.0;
+ an[2] = 0.0;
+ an[0] = 1.0;
+ break;
- /* threaded loop over nodes */
- //#pragma omp parallel for schedule(static)
- for(n=0; n<totnode; n++) {
- PBVHVertexIter vd;
- SculptBrushTest test;
+ case SCULPT_DISP_DIR_Y:
+ an[0] = 0.0;
+ an[2] = 0.0;
+ an[1] = 1.0;
+ break;
- SculptUndoNode *unode = sculpt_undo_push_node(ss, nodes[n]);
- sculpt_brush_test_init(ss, &test);
+ case SCULPT_DISP_DIR_Z:
+ an[0] = 0.0;
+ an[1] = 0.0;
+ an[2] = 1.0;
+ break;
- if(ss->cache->original) {
- BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
- if(sculpt_brush_test_fast(&test, unode->co[vd.i])) {
- float fno[3];
+ case SCULPT_DISP_DIR_AREA:
+ /* this calculates flatten center and area normal together,
+ amortizing the memory bandwidth and loop overhead to calculate both at the same time */
+ {
+ int n;
- normal_short_to_float_v3(fno, unode->no[vd.i]);
- add_norm_if(ss->cache->view_normal_symmetry, an, out_flip, fno);
- }
- }
- BLI_pbvh_vertex_iter_end;
- }
- else {
- BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
- if(sculpt_brush_test_fast(&test, vd.co)) {
- if(vd.no) {
- float fno[3];
+ float out_flip[3] = {0.0f, 0.0f, 0.0f};
- normal_short_to_float_v3(fno, vd.no);
- add_norm_if(ss->cache->view_normal_symmetry, an, out_flip, fno);
+ zero_v3(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 private_an[3] = {0.0f, 0.0f, 0.0f};
+ float private_out_flip[3] = {0.0f, 0.0f, 0.0f};
+ float private_fc[3] = {0.0f, 0.0f, 0.0f};
+ int private_count = 0;
+
+ unode = sculpt_undo_push_node(ss, nodes[n]);
+ sculpt_brush_test_init(ss, &test);
+
+ if(ss->cache->original) {
+ BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+ if(sculpt_brush_test_fast(&test, unode->co[vd.i])) {
+ float fno[3];
+
+ normal_short_to_float_v3(fno, unode->no[vd.i]);
+ add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, fno);
+ }
+ }
+ BLI_pbvh_vertex_iter_end;
+ }
+ else {
+ BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+ if(sculpt_brush_test_fast(&test, vd.co)) {
+ if(vd.no) {
+ float fno[3];
+
+ normal_short_to_float_v3(fno, vd.no);
+ add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, fno);
+ }
+ else {
+ add_norm_if(ss->cache->view_normal_symmetry, private_an, private_out_flip, vd.fno);
+ }
+ }
+ }
+ BLI_pbvh_vertex_iter_end;
+ }
+
+ #pragma omp critical
+ {
+ add_v3_v3(an, private_an);
+ add_v3_v3(out_flip, private_out_flip);
+ }
}
- else {
- add_norm_if(ss->cache->view_normal_symmetry, an, out_flip, vd.fno);
- }
- }
- }
- BLI_pbvh_vertex_iter_end;
- }
- }
- // openmp has a feature for doing final gathering, when
- // this is added back, use that instead of this below
- //#pragma omp critical
- //{
- // /* we sum per node and add together later for threads */
- // add_v3_v3(out, nout);
- // add_v3_v3(out_flip, nout_flip);
- //}
+ if (is_zero_v3(an))
+ copy_v3_v3(an, out_flip);
- if (is_zero_v3(an)) copy_v3_v3(an, out_flip);
+ normalize_v3(an);
+ }
- normalize_v3(an);
-
- switch (brush->sculpt_direction) {
- case SCULPT_DISP_DIR_VIEW:
- viewvector(ss->cache->vc->rv3d, ss->cache->vc->rv3d->twmat[3], an);
- break;
- case SCULPT_DISP_DIR_X:
- an[1] = 0.0;
- an[2] = 0.0;
- an[0] = 1.0;
- break;
- case SCULPT_DISP_DIR_Y:
- an[0] = 0.0;
- an[2] = 0.0;
- an[1] = 1.0;
- break;
- case SCULPT_DISP_DIR_Z:
- an[0] = 0.0;
- an[1] = 0.0;
- an[2] = 1.0;
- break;
- case SCULPT_DISP_DIR_AREA:
- default:
- break;
- }
+ default:
+ break;
+ }
- if (brush->sculpt_direction != SCULPT_DISP_DIR_AREA) {
- normalize_v3(an);
- flip_coord(an, an, ss->cache->symmetry_pass);
+ copy_v3_v3(ss->cache->last_area_normal, an);
+ copy_v3_v3(ss->cache->last_view_normal_symmetry, ss->cache->view_normal_symmetry);
}
-
- if ((!ss->cache->first_time)&&(brush->flag & BRUSH_ORIGINAL_NORMAL)) {
+ else {
copy_v3_v3(an, ss->cache->last_area_normal);
flip_coord(an, an, ss->cache->symmetry_pass);
+
copy_v3_v3(ss->cache->view_normal_symmetry, ss->cache->last_view_normal_symmetry);
flip_coord(ss->cache->view_normal_symmetry, ss->cache->view_normal_symmetry, ss->cache->symmetry_pass);
}
- else {
- if (ss->cache->symmetry_pass==0) {
- copy_v3_v3(ss->cache->last_area_normal, an);
- copy_v3_v3(ss->cache->last_view_normal_symmetry, ss->cache->view_normal_symmetry);
- }
- }
}
/* For the smooth brush, uses the neighboring vertices around vert to calculate
@@ -1080,7 +1088,7 @@
int iteration, n;
for(iteration = 0; iteration < 2; ++iteration) {
- //#pragma omp parallel for schedule(static)
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n=0; n<totnode; n++) {
if(ss->multires)
do_multires_smooth_brush(sd, ss, nodes[n], bstrength);
@@ -1113,7 +1121,7 @@
mul_v3_fl(offset, bstrength);
/* threaded loop over nodes */
- //#pragma omp parallel for schedule(static)
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1147,7 +1155,7 @@
float bstrength= ss->cache->bstrength;
int n;
- //#pragma omp parallel for schedule(static)
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1199,6 +1207,7 @@
add_v3_v3(grab_delta, an);
}
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1245,6 +1254,7 @@
cross_v3_v3v3(tmp, an, grab_delta);
cross_v3_v3v3(cono, tmp, an);
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1295,6 +1305,7 @@
add_v3_v3(grab_delta, an);
}
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1338,6 +1349,7 @@
cross_v3_v3v3(tmp, an, grab_delta);
cross_v3_v3v3(cono, tmp, an);
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n = 0; n < totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1382,6 +1394,7 @@
axis_angle_to_mat3(m, an, angle);
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1427,7 +1440,7 @@
mul_v3_v3v3(offset, ss->cache->scale, area_normal);
- //#pragma omp parallel for schedule(static)
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1485,7 +1498,7 @@
float bstrength= ss->cache->bstrength;
int n;
- //#pragma omp parallel for schedule(static)
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
for(n=0; n<totnode; n++) {
PBVHVertexIter vd;
SculptBrushTest test;
@@ -1516,46 +1529,32 @@
}
}
-static void calc_area_normal_and_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float an[3], float fc[3])
+static void calc_flatten_center(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode, float fc[3])
{
- Brush *brush = paint_brush(&sd->paint);
-
int n;
- // an
- float out_flip[3] = {0.0f, 0.0f, 0.0f};
-
- // fc
float count = 0;
- // an
- zero_v3(an);
-
- // fc
zero_v3(fc);
+ #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 private_an[3] = {0.0f, 0.0f, 0.0f};
+ float private_out_flip[3] = {0.0f, 0.0f, 0.0f};
+ float private_fc[3] = {0.0f, 0.0f, 0.0f};
+ int private_count = 0;
- // an
unode = sculpt_undo_push_node(ss, nodes[n]);
sculpt_brush_test_init(ss, &test);
if(ss->cache->original) {
-
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
if(sculpt_brush_test_fast(&test, unode->co[vd.i])) {
- // an
- float fno[3];
-
- normal_short_to_float_v3(fno, unode->no[vd.i]);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list