diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-06-27 02:48:27 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-06-27 02:48:49 +0400 |
commit | dbc04c594b941247be566f77754f9148235197ae (patch) | |
tree | c2959db6f792e9632138868163a902eb163bb494 /source | |
parent | 92ecbd2998c6324e017fecb10a5fb56b9d2f375e (diff) |
Fix T40758 Front facing not consistent in sculpt mode.
Some tools used view vector while others used the area normal.
Area Normal -is- useful and it will have to be incorporated to the
system better, but I'd like to do it in a way that is well
collaborating with sculpt plane calculation too, because it will have
to be slightly more expensive, i.e normal calculated before the plane,
never together, so only front to the area normal influence can be kept.
Currently sculpt plane takes into consideration view vector, but that
can produce an unwanted normal/plane at glancing angles on mesh edges.
Another issue that arises here is whether we do an actual calculation of
sculpt normal for each symmetry pass or we just flip the initial (former
is more expensive but more correct)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 3f39dc7b6ec..735238ac89b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -226,7 +226,7 @@ typedef struct StrokeCache { float sculpt_normal[3]; float sculpt_normal_symm[3]; - /* Used for wrap texture mode, local_mat gets calculated by + /* Used for area texture mode, local_mat gets calculated by * calc_brush_local_mat() and used in tex_strength(). */ float brush_local_mat[4][4]; @@ -873,7 +873,6 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) static float tex_strength(SculptSession *ss, Brush *br, const float point[3], const float len, - const float sculpt_normal[3], const short vno[3], const float fno[3], const float mask) @@ -944,7 +943,7 @@ static float tex_strength(SculptSession *ss, Brush *br, /* Falloff curve */ avg *= BKE_brush_curve_strength(br, len, cache->radius); - avg *= frontface(br, sculpt_normal, vno, fno); + avg *= frontface(br, cache->view_normal, vno, fno); /* Paint mask */ avg *= 1.0f - mask; @@ -1400,7 +1399,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno, + vd.no, vd.fno, smooth_mask ? 0 : (vd.mask ? *vd.mask : 0.0f)); if (smooth_mask) { float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask; @@ -1441,7 +1440,7 @@ static void do_bmesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno, + vd.no, vd.fno, smooth_mask ? 0 : *vd.mask); if (smooth_mask) { float val = bmesh_neighbor_average_mask(ss->bm, vd.bm_vert) - *vd.mask; @@ -1593,7 +1592,6 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no if (sculpt_brush_test(&test, co)) { const float strength_mask = (smooth_mask ? 0 : *mask); const float fade = bstrength * tex_strength(ss, brush, co, test.dist, - ss->cache->view_normal, NULL, fno, strength_mask); float n = 1.0f / 16.0f; @@ -1696,7 +1694,7 @@ static void do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int tot { if (sculpt_brush_test(&test, vd.co)) { float fade = tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno, 0); + vd.no, vd.fno, 0); (*vd.mask) += fade * bstrength; CLAMP(*vd.mask, 0, 1); @@ -1752,8 +1750,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) { if (sculpt_brush_test(&test, vd.co)) { /* offset vertex */ - float fade = tex_strength(ss, brush, vd.co, test.dist, - ss->cache->sculpt_normal_symm, vd.no, + float fade = tex_strength(ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], offset, fade); @@ -1809,7 +1806,6 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod if (sculpt_brush_test(&test, vd.co)) { /* offset vertex */ const float fade = tex_strength(ss, brush, vd.co, test.dist, - ss->cache->sculpt_normal_symm, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); float val1[3]; float val2[3]; @@ -1851,8 +1847,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode BKE_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, - ss->cache->view_normal, vd.no, + float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); float val[3]; @@ -1907,7 +1902,6 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) const float fade = bstrength * tex_strength(ss, brush, orig_data.co, test.dist, - ss->cache->sculpt_normal_symm, orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f); @@ -1949,7 +1943,6 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->sculpt_normal_symm, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], cono, fade); @@ -1998,7 +1991,6 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->sculpt_normal_symm, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); @@ -2046,7 +2038,6 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode const float fade = bstrength * tex_strength(ss, brush, orig_data.co, test.dist, - ss->cache->sculpt_normal_symm, orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f); @@ -2091,7 +2082,6 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod const float fade = bstrength * tex_strength(ss, brush, orig_data.co, test.dist, - ss->cache->sculpt_normal_symm, orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f); @@ -2147,7 +2137,6 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode if (sculpt_brush_test(&test, orig_data.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->sculpt_normal_symm, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); float *disp = &layer_disp[vd.i]; float val[3]; @@ -2201,7 +2190,6 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); float val[3]; @@ -2614,7 +2602,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); + vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2686,9 +2674,8 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sub_v3_v3v3(val, intr, vd.co); if (plane_trim(ss->cache, brush, val)) { - const float fade = bstrength * tex_strength(ss, brush, vd.co, - sqrt(test.dist), - an, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); + const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), + vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2790,7 +2777,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, ss->cache->radius * test.dist, - an, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); + vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2854,7 +2841,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); + vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2918,7 +2905,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); + vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2960,8 +2947,7 @@ static void do_gravity(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, fl BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { if (sculpt_brush_test_sq(&test, vd.co)) { - const float fade = tex_strength(ss, brush, vd.co, sqrt(test.dist), - ss->cache->sculpt_normal_symm, vd.no, + const float fade = tex_strength(ss, brush, vd.co, sqrt(test.dist), vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f); mul_v3_v3fl(proxy[vd.i], offset, fade); |