diff options
author | Pablo Dobarro <pablodp606> | 2020-10-22 20:06:00 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-10-22 20:17:07 +0300 |
commit | 383c20a6abd6591a3a402504b37fdecaa64fde0f (patch) | |
tree | 57a154231ccbf7acd6454c498cdf12b8f2ed38fa /source/blender/editors | |
parent | b5169cd2301a021a367fcaee69aa66c262565bb3 (diff) |
Sculpt: Grab silhouette option
This adds a property to the grab that masks vertices based on its
original normal and grab delta. When used on thin meshes, it allows to
grab the silhouette from one side of the object without affecting the
shape of the other side.
Reviewed By: sergey
Differential Revision: https://developer.blender.org/D9205
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 3ffa2091560..8e7935e821d 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3805,20 +3805,33 @@ static void do_grab_brush_task_cb_ex(void *__restrict userdata, ss, &test, data->brush->falloff_shape); const int thread_id = BLI_task_parallel_thread_id(tls); + const bool grab_silhouette = brush->flag2 & BRUSH_GRAB_SILHOUETTE; + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { SCULPT_orig_vert_data_update(&orig_data, &vd); if (sculpt_brush_test_sq_fn(&test, orig_data.co)) { - const float fade = bstrength * SCULPT_brush_strength_factor(ss, - brush, - orig_data.co, - sqrtf(test.dist), - orig_data.no, - NULL, - vd.mask ? *vd.mask : 0.0f, - vd.index, - thread_id); + float fade = bstrength * SCULPT_brush_strength_factor(ss, + brush, + orig_data.co, + sqrtf(test.dist), + orig_data.no, + NULL, + vd.mask ? *vd.mask : 0.0f, + vd.index, + thread_id); + + if (grab_silhouette) { + float silhouette_test_dir[3]; + normalize_v3_v3(silhouette_test_dir, grab_delta); + if (dot_v3v3(ss->cache->initial_normal, ss->cache->grab_delta) < 0.0f) { + mul_v3_fl(silhouette_test_dir, -1.0f); + } + float vno[3]; + normal_short_to_float_v3(vno, orig_data.no); + fade *= max_ff(dot_v3v3(vno, silhouette_test_dir), 0.0f); + } mul_v3_v3fl(proxy[vd.i], grab_delta, fade); |