Fix T42893: Skin Modifier, changes randomly toggling editmode
authorCampbell Barton <ideasman42@gmail.com>
Mon, 4 May 2015 10:36:43 +0000 (20:36 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 4 May 2015 10:56:57 +0000 (20:56 +1000)
Own regression, previously it would do a full mesh normal calculation for each isolated shape
(could hang on meshes with many loose parts).

However the normals are needed, instead of doing a full calculation,
just set normals on new faces.

Thanks to Brecht for finding cause!

source/blender/modifiers/intern/MOD_skin.c

index 02515360f3a39d16556c1d8023c5025bbf78b4bf..155c76638f9c17cd6c9fba99508e99104ed13ca0 100644 (file)
@@ -249,6 +249,7 @@ static bool build_hull(SkinOutput *so, Frame **frames, int totframe)
 
        /* Apply face attributes to hull output */
        BMO_ITER (f, &oiter, op.slots_out, "geom.out", BM_FACE) {
+               BM_face_normal_update(f);
                if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING)
                        BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
                f->mat_nr = so->mat_nr;
@@ -960,6 +961,7 @@ static void add_poly(SkinOutput *so,
        BLI_assert(v1 && v2 && v3);
 
        f = BM_face_create_verts(so->bm, verts, v4 ? 4 : 3, NULL, BM_CREATE_NO_DOUBLE, true);
+       BM_face_normal_update(f);
        if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING)
                BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
        f->mat_nr = so->mat_nr;
@@ -1421,6 +1423,9 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd)
                        if (adj[0]->len == 3 && adj[1]->len == 3) {
                                BMVert *quad[4];
 
+                               BLI_assert(BM_face_is_normal_valid(adj[0]));
+                               BLI_assert(BM_face_is_normal_valid(adj[1]));
+
                                /* Construct quad using the two triangles adjacent to
                                 * the edge */
                                quad_from_tris(e, adj, quad);