diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2018-12-05 20:24:05 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2018-12-08 08:27:37 +0300 |
commit | b4b224dc083c0e490eebc5c98646d791a41b8563 (patch) | |
tree | b29d595a9003836a065b21f4e1a8044e0fc6b155 /source/blender/blenkernel/intern/shrinkwrap.c | |
parent | 1ddfd8c9ec1d61fa62dfe6adb37c4789476bc4e6 (diff) |
Shrinkwrap: use polygon normals for flat faces in Align To Normal.
Hit normal originates from tesselated triangles and isn't the
actual normal used for shading of flat faces. Thus, it is better
to use the actual polygon normals when available.
Diffstat (limited to 'source/blender/blenkernel/intern/shrinkwrap.c')
-rw-r--r-- | source/blender/blenkernel/intern/shrinkwrap.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index ee35876f2a3..06e5cc9e849 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -144,6 +144,7 @@ bool BKE_shrinkwrap_init_tree(ShrinkwrapTreeData *data, Mesh *mesh, int shrinkTy } if (force_normals || BKE_shrinkwrap_needs_normals(shrinkType, shrinkMode)) { + data->pnors = CustomData_get_layer(&mesh->pdata, CD_NORMAL); if ((mesh->flag & ME_AUTOSMOOTH) != 0) { data->clnors = CustomData_get_layer(&mesh->ldata, CD_NORMAL); } @@ -1164,7 +1165,11 @@ void BKE_shrinkwrap_compute_smooth_normal( normalize_v3(r_no); } } - /* Use the looptri normal if flat. */ + /* Use the polygon normal if flat. */ + else if (tree->pnors != NULL) { + copy_v3_v3(r_no, tree->pnors[tri->poly]); + } + /* Finally fallback to the looptri normal. */ else { copy_v3_v3(r_no, hit_no); } |