Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-08-03 05:19:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-08-03 05:22:11 +0300
commit04c75c5ce7699a1502a7c2212d4aa57166465514 (patch)
treea1822fe961700da7cf5c611f168a037f592a1783 /source/blender/editors/mesh/editmesh_tools.c
parent223f0481382cc6019c79568f6136c4d59d4ec543 (diff)
Edit Mesh: Correct normal calculation for "Set From Faces"
Setting normals from faces wasn't weighting the faces contribution by the corner angle, giving lop-sided results in some cases. This removes the epsilon check for CLNORS_VALID_VEC_LEN, in favor of matching the behavior of vertex normals exactly.
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 41a9f426798..7e94383390e 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -9538,18 +9538,11 @@ static int edbm_set_normals_from_faces_exec(bContext *C, wmOperator *op)
BKE_editmesh_ensure_autosmooth(em, obedit->data);
BKE_editmesh_lnorspace_update(em, obedit->data);
- float(*vnors)[3] = MEM_callocN(sizeof(*vnors) * bm->totvert, __func__);
- BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
- if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
- BM_ITER_ELEM (v, &viter, f, BM_VERTS_OF_FACE) {
- const int v_index = BM_elem_index_get(v);
- add_v3_v3(vnors[v_index], f->no);
- }
- }
- }
- for (int i = 0; i < bm->totvert; i++) {
- if (!is_zero_v3(vnors[i]) && normalize_v3(vnors[i]) < CLNORS_VALID_VEC_LEN) {
- zero_v3(vnors[i]);
+ float(*vnors)[3] = MEM_mallocN(sizeof(*vnors) * bm->totvert, __func__);
+ {
+ int v_index;
+ BM_ITER_MESH_INDEX (v, &viter, bm, BM_VERTS_OF_MESH, v_index) {
+ BM_vert_calc_normal_ex(v, BM_ELEM_SELECT, vnors[v_index]);
}
}