diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-04-15 08:22:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-04-15 08:27:27 +0300 |
commit | 356ceded279b190bfca801afe25323efadd40571 (patch) | |
tree | e6bb52f789dc8b9d84f8c94fbe16b5b6d3a98ad0 /source | |
parent | b216f7abd6ba4311918ee84bf051fac3d96faf5f (diff) |
Sculpt: change behavior of crease brush
Pinch would give a flat result on either side of the stroke,
because points were dragged towards a single point.
Now pinch is projected on the sculpt plane, which gives a tighter crease.
The reverse is true too - blob brush which shares the code is also more curved.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 6ca368ea4f7..411ccefe5c0 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1699,6 +1699,16 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod float brush_alpha; int n; + /* vars for handling projection when calculating the pinch vector. + * Use surface normal for 'v_proj',s o the vertices are pinched towards a line instead of a single point. + * Without this we get a 'flat' surface surrounding the pinch */ + const float *pinch_proj = ss->cache->sculpt_normal_symm; + const float pinch_proj_len_sq = len_squared_v3(pinch_proj); + const bool do_pinch_proj = (pinch_proj_len_sq > FLT_EPSILON); + /* simplifies projection calc below */ + const float pinch_proj_len_sq_inv_neg = do_pinch_proj ? -1.0f / pinch_proj_len_sq : 0.0f; + + /* offset with as much as possible factored in already */ mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius); mul_v3_v3(offset, ss->cache->scale); @@ -1739,6 +1749,15 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sub_v3_v3v3(val1, test.location, vd.co); mul_v3_fl(val1, fade * flippedbstrength); + if (do_pinch_proj) { +#if 0 + project_plane_v3_v3v3(val1, val1, v_proj); +#else + /* inline the projection, cache `-1.0 / dot_v3_v3(v_proj, v_proj)` */ + madd_v3_v3fl(val1, pinch_proj, dot_v3v3(val1, pinch_proj) * pinch_proj_len_sq_inv_neg); +#endif + } + /* then we draw */ mul_v3_v3fl(val2, offset, fade); |