GSOC 2013 paint
[blender-staging.git] / source / blender / editors / sculpt_paint / sculpt_undo.c
index 9beb11ec2f4c4022873a094882b750d3f643b446..614c1f3ef1d4c7b21938ef7725a52e073763d592 100644 (file)
@@ -62,7 +62,8 @@
 
 #include "GPU_buffers.h"
 
-#include "ED_sculpt.h"
+#include "ED_paint.h"
+
 #include "bmesh.h"
 #include "paint_intern.h"
 #include "sculpt_intern.h"
@@ -195,9 +196,9 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm,
                
                for (i = 0; i < unode->totvert; i++) {
                        MVert *v = &mvert[unode->index[i]];
-                       int uval = BLI_BITMAP_GET(unode->vert_hidden, i);
+                       int uval = BLI_BITMAP_TEST(unode->vert_hidden, i);
 
-                       BLI_BITMAP_MODIFY(unode->vert_hidden, i,
+                       BLI_BITMAP_SET(unode->vert_hidden, i,
                                          v->flag & ME_HIDE);
                        if (uval)
                                v->flag |= ME_HIDE;
@@ -542,17 +543,16 @@ static void sculpt_undo_free(ListBase *lb)
        }
 }
 
-bool sculpt_undo_cleanup(bContext *C, ListBase *lb) {
+static bool sculpt_undo_cleanup(bContext *C, ListBase *lb)
+{
        Object *ob = CTX_data_active_object(C);
        SculptUndoNode *unode;
 
        unode = lb->first;
 
-       if (strcmp(unode->idname, ob->id.name) != 0) {
-               for (unode = lb->first; unode; unode = unode->next) {
-                       if (unode->bm_entry)
-                               BM_log_cleanup_entry(unode->bm_entry);
-               }
+       if (unode && strcmp(unode->idname, ob->id.name) != 0) {
+               if (unode->bm_entry)
+                       BM_log_cleanup_entry(unode->bm_entry);
 
                return true;
        }
@@ -701,7 +701,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
                BKE_pbvh_node_num_verts(pbvh, node, NULL, &allvert);
                BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert);
                for (i = 0; i < allvert; i++) {
-                       BLI_BITMAP_MODIFY(unode->vert_hidden, i,
+                       BLI_BITMAP_SET(unode->vert_hidden, i,
                                          mvert[vert_indices[i]].flag & ME_HIDE);
                }
        }
@@ -879,7 +879,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
 void sculpt_undo_push_begin(const char *name)
 {
        ED_undo_paint_push_begin(UNDO_PAINT_MESH, name,
-                                                 sculpt_undo_restore, sculpt_undo_free);
+                                sculpt_undo_restore, sculpt_undo_free, sculpt_undo_cleanup);
 }
 
 void sculpt_undo_push_end(void)