Fix bug #30778, sculpt w/ modifiers + undo causes collapse of vertices
authorNicholas Bishop <nicholasbishop@gmail.com>
Tue, 3 Apr 2012 18:41:40 +0000 (18:41 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Tue, 3 Apr 2012 18:41:40 +0000 (18:41 +0000)
Was caused by earlier refactoring of undo, used index array
before it gets initialized. Fixed by swapping order of copying.

Also changed normals calculation on undo restore to operate on
tessellated data (which sculpt still uses), fixes console warning
print.

source/blender/editors/sculpt_paint/sculpt_undo.c

index 5378ce7872a6d38310dcc9f1777259147fe4f3ac..89a786d02a9b38bfbb1e8bd1de724f1e52759758 100644 (file)
@@ -274,7 +274,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
 
                if (ss->modifiers_active) {
                        Mesh *mesh = ob->data;
-                       mesh_calc_normals_mapping(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL);
+                       mesh_calc_normals_tessface(mesh->mvert, mesh->totvert,
+                                                                          mesh->mface, mesh->totface, NULL);
 
                        free_sculptsession_deformMats(ss);
                        tag_update |= 1;
@@ -471,14 +472,6 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
        BLI_unlock_thread(LOCK_CUSTOM1);
 
        /* copy threaded, hopefully this is the performance critical part */
-       switch (type) {
-               case SCULPT_UNDO_COORDS:
-                       sculpt_undo_store_coords(ob, unode);
-                       break;
-               case SCULPT_UNDO_HIDDEN:
-                       sculpt_undo_store_hidden(ob, unode);
-                       break;
-       }
 
        if (unode->grids) {
                int totgrid, *grids;
@@ -493,6 +486,15 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
                memcpy(unode->index, vert_indices, sizeof(int) * unode->totvert);
        }
 
+       switch (type) {
+               case SCULPT_UNDO_COORDS:
+                       sculpt_undo_store_coords(ob, unode);
+                       break;
+               case SCULPT_UNDO_HIDDEN:
+                       sculpt_undo_store_hidden(ob, unode);
+                       break;
+       }
+
        /* store active shape key */
        if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name));
        else unode->shapeName[0] = '\0';