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:
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 5dc4ffcad18..4de7143682a 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -2035,19 +2035,26 @@ static bool flip_custom_normals(BMesh *bm, BMLoopNorEditDataArray *lnors_ed_arr)
}
BMFace *f;
- BMLoop *l;
- BMIter iter_f, iter_l;
+ BMLoop *l, *l_start;
+ BMIter iter_f;
BM_ITER_MESH (f, &iter_f, bm, BM_FACES_OF_MESH) {
+ /* Flip all the custom loop normals on the selected faces. */
if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) {
continue;
}
- /* Flip all the custom loop normals on the selected faces. */
- BM_ITER_ELEM (l, &iter_l, f, BM_LOOPS_OF_FACE) {
+ /* Because the winding has changed, we need to go the reverse way around the face to get the
+ * correct placement of the normals. However we need to derive the old loop index to get the
+ * correct data. Note that the first loop index is the same though. So the loop starts and ends
+ * in the same place as before the flip.
+ */
+ l_start = l = BM_FACE_FIRST_LOOP(f);
+ int old_index = BM_elem_index_get(l);
+ do {
int loop_index = BM_elem_index_get(l);
- BMLoopNorEditData *lnor_ed = lnors_ed_arr->lidx_to_lnor_editdata[loop_index];
+ BMLoopNorEditData *lnor_ed = lnors_ed_arr->lidx_to_lnor_editdata[old_index];
BMLoopNorEditData *lnor_ed_new = lnors_ed_arr_new_full->lidx_to_lnor_editdata[loop_index];
BLI_assert(lnor_ed != NULL && lnor_ed_new != NULL);
@@ -2055,7 +2062,10 @@ static bool flip_custom_normals(BMesh *bm, BMLoopNorEditDataArray *lnors_ed_arr)
BKE_lnor_space_custom_normal_to_data(
bm->lnor_spacearr->lspacearr[loop_index], lnor_ed->nloc, lnor_ed_new->clnors_data);
- }
+
+ old_index++;
+ l = l->prev;
+ } while (l != l_start);
}
BM_loop_normal_editdata_array_free(lnors_ed_arr_new_full);
return true;
@@ -4172,7 +4182,8 @@ static Base *mesh_separate_tagged(
BKE_object_material_array_assign(bmain,
base_new->object,
BKE_object_material_array_p(obedit),
- *BKE_object_material_len_p(obedit));
+ *BKE_object_material_len_p(obedit),
+ false);
ED_object_base_select(base_new, BA_SELECT);
@@ -4244,7 +4255,8 @@ static Base *mesh_separate_arrays(Main *bmain,
BKE_object_material_array_assign(bmain,
base_new->object,
BKE_object_material_array_p(obedit),
- *BKE_object_material_len_p(obedit));
+ *BKE_object_material_len_p(obedit),
+ false);
ED_object_base_select(base_new, BA_SELECT);