Fix T40691, dyntopo changes lost on save if sculpting on multiple
authorAntony Riakiotakis <kalast@gmail.com>
Thu, 26 Jun 2014 20:57:00 +0000 (23:57 +0300)
committerAntony Riakiotakis <kalast@gmail.com>
Thu, 26 Jun 2014 20:57:33 +0000 (23:57 +0300)
objects.

Flush edits for all objects, not just the active one. Here we might want
to disallow leaving an object on sculpt mode when selecting another, but
this works, no need to enforce it.

source/blender/editors/util/ed_util.c

index c27e0b80b025c7f8d6358a227e868b1fa1362015..47fbfbe3eba1492403a1f4e99d6e431f945b9f09 100644 (file)
@@ -155,25 +155,27 @@ void ED_editors_exit(bContext *C)
  * rendering, copying, etc. */
 void ED_editors_flush_edits(const bContext *C, bool for_render)
 {
-       Object *obact = CTX_data_active_object(C);
+       Object *ob;
        Object *obedit = CTX_data_edit_object(C);
-
+       Main *bmain = CTX_data_main(C);
        /* get editmode results */
        if (obedit)
                ED_object_editmode_load(obedit);
 
-       if (obact && (obact->mode & OB_MODE_SCULPT)) {
-               /* flush multires changes (for sculpt) */
-               multires_force_update(obact);
+       for (ob = bmain->object.first; ob; ob = ob->id.next) {
+               if (ob && (ob->mode & OB_MODE_SCULPT)) {
+                       /* flush multires changes (for sculpt) */
+                       multires_force_update(ob);
 
-               if (for_render) {
-                       /* flush changes from dynamic topology sculpt */
-                       BKE_sculptsession_bm_to_me_for_render(obact);
-               }
-               else {
-                       /* Set reorder=false so that saving the file doesn't reorder
+                       if (for_render) {
+                               /* flush changes from dynamic topology sculpt */
+                               BKE_sculptsession_bm_to_me_for_render(ob);
+                       }
+                       else {
+                               /* Set reorder=false so that saving the file doesn't reorder
                         * the BMesh's elements */
-                       BKE_sculptsession_bm_to_me(obact, false);
+                               BKE_sculptsession_bm_to_me(ob, false);
+                       }
                }
        }
 }