Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-04-17 20:09:16 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-04-17 20:09:16 +0300
commitb0c2fdd927d1478ca76a312442f0c452a704607f (patch)
tree1a6a92673298ec4a5ff9b71f9e3689fdd0d7bbfb /source/blender/editors/sculpt_paint/sculpt.c
parent28b9a0276fd6cfce0da7a8f434c13b252fc2cbbb (diff)
Cleanup: simplify sculpt normal accumulation
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c84
1 files changed, 35 insertions, 49 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 436375707e7..63b95aa9c64 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2156,73 +2156,59 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
PBVHVertexIter vd;
SculptBrushTest test;
SculptUndoNode *unode;
- float private_fc[3] = {0.0f, 0.0f, 0.0f};
- float private_fc_flip[3] = {0.0f, 0.0f, 0.0f};
- int private_count = 0;
- int private_count_flip = 0;
+ /* 0=towards view, 1=flipped */
+ float private_co[2][3] = {{0.0f}};
+ int private_count[2] = {0, 0};
+ bool use_original;
unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS);
sculpt_brush_test_init(ss, &test);
- if (ss->cache->original && unode->co) {
- BKE_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];
+ use_original = (ss->cache->original && unode->co);
- normal_short_to_float_v3(fno, unode->no[vd.i]);
- if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
- add_v3_v3(private_fc, unode->co[vd.i]);
- private_count++;
- }
- else {
- add_v3_v3(private_fc_flip, unode->co[vd.i]);
- private_count_flip++;
- }
- }
+ BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
+ {
+ const float *co;
+
+ if (use_original) {
+ co = unode->co[vd.i];
+ }
+ else {
+ co = vd.co;
}
- BKE_pbvh_vertex_iter_end;
- }
- else {
- BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
- {
- if (sculpt_brush_test_fast(&test, vd.co)) {
- /* for area normal */
- if (vd.no) {
- float fno[3];
- normal_short_to_float_v3(fno, vd.no);
+ if (sculpt_brush_test_fast(&test, co)) {
+ float no_buf[3];
+ const float *no;
+ int flip_index;
- if (dot_v3v3(ss->cache->view_normal, fno) > 0) {
- add_v3_v3(private_fc, vd.co);
- private_count++;
- }
- else {
- add_v3_v3(private_fc_flip, vd.co);
- private_count_flip++;
- }
+ if (use_original) {
+ normal_short_to_float_v3(no_buf, unode->no[vd.i]);
+ no = no_buf;
+ }
+ else {
+ if (vd.no) {
+ normal_short_to_float_v3(no_buf, vd.no);
+ no = no_buf;
}
else {
- if (dot_v3v3(ss->cache->view_normal, vd.fno) > 0) {
- add_v3_v3(private_fc, vd.co);
- private_count++;
- }
- else {
- add_v3_v3(private_fc_flip, vd.co);
- private_count_flip++;
- }
+ no = vd.fno;
}
}
+
+ flip_index = (dot_v3v3(ss->cache->view_normal, no) <= 0.0f);
+ add_v3_v3(private_co[flip_index], co);
+ private_count[flip_index] += 1;
}
BKE_pbvh_vertex_iter_end;
}
#pragma omp critical
{
- add_v3_v3(fc, private_fc);
- add_v3_v3(fc_flip, private_fc_flip);
- count += private_count;
- count_flip += private_count_flip;
+ add_v3_v3(fc, private_co[0]);
+ add_v3_v3(fc_flip, private_co[1]);
+ count += private_count[0];
+ count_flip += private_count[1];
}
}
if (count != 0)