From 66d9c0def922db300cda6d1987f2e0c0d5abd782 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 25 Jul 2013 18:16:55 +0000 Subject: [PATCH] fix for face normal flipping calculation. --- source/blender/bmesh/intern/bmesh_construct.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 39b127c410e..40c1c956a2e 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -200,6 +200,8 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, c ev1 = edges[0]->v1; ev2 = edges[0]->v2; + BLI_assert(ELEM(v1, ev1, ev2) && ELEM(v2, ev1, ev2)); + if (v1 == ev2) { /* Swapping here improves performance and consistency of face * structure in the special case that the edges are already in @@ -344,6 +346,7 @@ BMFace *BM_face_create_ngon_verts(BMesh *bm, BMVert **vert_arr, const int len, c /* we want to use the reverse winding to the existing order */ BM_edge_ordered_verts(edge_arr[i], &test_v2, &test_v1); winding[(vert_arr[i_prev] == test_v2)]++; + BLI_assert(vert_arr[i_prev] == test_v2 || vert_arr[i_prev] == test_v1); } } @@ -370,7 +373,11 @@ BMFace *BM_face_create_ngon_verts(BMesh *bm, BMVert **vert_arr, const int len, c /* --- */ /* create the face */ - return BM_face_create_ngon(bm, vert_arr[winding[0]], vert_arr[winding[1]], edge_arr, len, create_flag); + return BM_face_create_ngon( + bm, + vert_arr[(len - 2) + winding[0]], + vert_arr[(len - 1) + winding[1]], + edge_arr, len, create_flag); }