diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-12-12 18:34:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-12-12 18:34:21 +0400 |
commit | 96cad133f75b22a3ac8045fefe18239bef5a4bf9 (patch) | |
tree | 72b0083b7e63e4bbc54f6d85b2b32809a8ff20fe /source/blender/editors | |
parent | bee7c20a97e2e4fc72926a22db7409ab1b161f24 (diff) |
fix [#33489] Scaling normals with Alt (maintains shell thickness) producing wrong result.
not exactly a bug - zero area faces from a cancelled extrude gave issues - but this is a common use case, so make it work by only using selected faces when calculating the vertex shell thickness.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 884ec03cc62..5497b421981 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1879,6 +1879,40 @@ static void get_edge_center(float cent_r[3], BMVert *eve) } } +/* local version of #BM_vert_calc_shell_factor which only + * uses selected faces */ +static float bm_vert_calc_shell_factor_selected(BMVert *v) +{ + BMIter iter; + BMLoop *l; + float accum_shell = 0.0f; + float accum_angle = 0.0f; + int tot_sel = 0, tot = 0; + + BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { + if (BM_elem_flag_test(l->f, BM_ELEM_SELECT)) { /* <-- only difference to BM_vert_calc_shell_factor! */ + const float face_angle = BM_loop_calc_face_angle(l); + accum_shell += shell_angle_to_dist(angle_normalized_v3v3(v->no, l->f->no)) * face_angle; + accum_angle += face_angle; + tot_sel++; + } + tot++; + } + + if (accum_angle != 0.0f) { + return accum_shell / accum_angle; + } + else { + if (tot != 0 && tot_sel == 0) { + /* none selected, so use all */ + return BM_vert_calc_shell_factor(v); + } + else { + return 1.0f; + } + } +} + /* way to overwrite what data is edited with transform */ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx, BMEditMesh *em, BMVert *eve, float *bweight) @@ -1927,7 +1961,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx } else if (t->mode == TFM_SHRINKFATTEN) { td->ext = tx; - tx->isize[0] = BM_vert_calc_shell_factor(eve); + tx->isize[0] = bm_vert_calc_shell_factor_selected(eve); } } |