[Bf-blender-cvs] [018fe81] master: Fix T38269: scene full copy in mesh edit or sculpt mode did not copy mesh edits.

Brecht Van Lommel noreply at git.blender.org
Mon Jan 20 14:27:19 CET 2014


Commit: 018fe81779e81ad43b16c74969764ae3b71d4b40
Author: Brecht Van Lommel
Date:   Mon Jan 20 14:11:12 2014 +0100
https://developer.blender.org/rB018fe81779e81ad43b16c74969764ae3b71d4b40

Fix T38269: scene full copy in mesh edit or sculpt mode did not copy mesh edits.

===================================================================

M	source/blender/editors/include/ED_sculpt.h
M	source/blender/editors/include/ED_util.h
M	source/blender/editors/render/render_internal.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/util/ed_util.c
M	source/blender/windowmanager/intern/wm_files.c

===================================================================

diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h
index 4c6c409..ba69be5 100644
--- a/source/blender/editors/include/ED_sculpt.h
+++ b/source/blender/editors/include/ED_sculpt.h
@@ -44,7 +44,6 @@ struct rcti;
 void ED_operatortypes_sculpt(void);
 void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar,
                               struct RegionView3D *rv3d, struct Object *ob);
-void ED_sculpt_force_update(struct bContext *C);
 void ED_sculpt_get_average_stroke(struct Object *ob, float stroke[3]);
 int ED_sculpt_minmax(struct bContext *C, float min[3], float max[3]);
 int ED_sculpt_mask_layers_ensure(struct Object *ob,
diff --git a/source/blender/editors/include/ED_util.h b/source/blender/editors/include/ED_util.h
index 7f642db..fa0e5b6 100644
--- a/source/blender/editors/include/ED_util.h
+++ b/source/blender/editors/include/ED_util.h
@@ -46,6 +46,8 @@ struct Mesh;
 void    ED_editors_init(struct bContext *C);
 void    ED_editors_exit(struct bContext *C);
 
+void    ED_editors_flush_edits(struct bContext *C, bool for_render);
+
 /* ************** Undo ************************ */
 
 /* undo.c */
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index ae3ccf6..b2eefe6 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -70,6 +70,7 @@
 #include "ED_object.h"
 #include "ED_render.h"
 #include "ED_screen.h"
+#include "ED_util.h"
 #include "ED_view3d.h"
 
 #include "RE_pipeline.h"
@@ -772,11 +773,8 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
 	/* handle UI stuff */
 	WM_cursor_wait(1);
 
-	/* flush multires changes (for sculpt) */
-	multires_force_render_update(active_object);
-
-	/* flush changes from dynamic topology sculpt */
-	sculptsession_bm_to_me_for_render(active_object);
+	/* flush sculpt and editmode changes */
+	ED_editors_flush_edits(C, true);
 
 	/* cleanup sequencer caches before starting user triggered render.
 	 * otherwise, invalidated cache entries can make their way into
@@ -784,9 +782,6 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
 	 * since sequence rendering can call that recursively... (peter) */
 	BKE_sequencer_cache_cleanup();
 
-	/* get editmode results */
-	ED_object_editmode_load(CTX_data_edit_object(C));
-
 	// store spare
 	// get view3d layer, local layer, make this nice api call to render
 	// store spare
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index eba8028..9051b20 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -3649,6 +3649,7 @@ static int scene_new_exec(bContext *C, wmOperator *op)
 			ED_object_single_users(bmain, newscene, false, true);
 		}
 		else if (type == SCE_COPY_FULL) {
+			ED_editors_flush_edits(C, false);
 			ED_object_single_users(bmain, newscene, true, true);
 		}
 	}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 8c3024e..331701c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -104,19 +104,6 @@
 #include <omp.h>
 #endif
 
-void ED_sculpt_force_update(bContext *C)
-{
-	Object *ob = CTX_data_active_object(C);
-
-	if (ob && (ob->mode & OB_MODE_SCULPT)) {
-		multires_force_update(ob);
-
-		/* Set reorder=false so that saving the file doesn't reorder
-		 * the BMesh's elements */
-		sculptsession_bm_to_me(ob, FALSE);
-	}
-}
-
 void ED_sculpt_get_average_stroke(Object *ob, float stroke[3])
 {
 	if (ob->sculpt->last_stroke_valid && ob->sculpt->average_stroke_counter > 0) {
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index df1dad6..ab4cd16 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -51,7 +51,9 @@
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
+#include "BKE_multires.h"
 #include "BKE_packedFile.h"
+#include "BKE_paint.h"
 
 #include "ED_armature.h"
 #include "ED_image.h"
@@ -139,6 +141,32 @@ void ED_editors_exit(bContext *C)
 	mesh_mirrtopo_table(NULL, 'e');
 }
 
+/* flush any temp data from object editing to DNA before writing files,
+ * rendering, copying, etc. */
+void ED_editors_flush_edits(bContext *C, bool for_render)
+{
+    Object *obact = CTX_data_active_object(C);
+    Object *obedit = CTX_data_edit_object(C);
+
+    /* get editmode results */
+	if (obedit)
+	    ED_object_editmode_load(CTX_data_edit_object(C));
+
+    if (obact && (obact->mode & OB_MODE_SCULPT)) {
+    	/* flush multires changes (for sculpt) */
+        multires_force_update(obact);
+
+		if (for_render) {
+			/* flush changes from dynamic topology sculpt */
+			sculptsession_bm_to_me_for_render(obact);
+		}
+		else {
+			/* Set reorder=false so that saving the file doesn't reorder
+			 * the BMesh's elements */
+			sculptsession_bm_to_me(obact, FALSE);
+		}
+    }
+}
 
 /* ***** XXX: functions are using old blender names, cleanup later ***** */
 
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index c4c91b4..71d78a8 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -871,22 +871,6 @@ bool write_crash_blend(void)
 }
 
 /**
- * Flush any temp data from object editing to DNA before writing the blend file to disk.
- */
-static void write_flush_editdata(bContext *C)
-{
-	Object *obedit;
-
-	obedit = CTX_data_edit_object(C);
-
-	if (obedit) {
-		ED_object_editmode_load(obedit);
-	}
-
-	ED_sculpt_force_update(C);
-}
-
-/**
  * \see #wm_homefile_write_exec wraps #BLO_write_file in a similar way.
  */
 int wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList *reports)
@@ -943,7 +927,7 @@ int wm_file_write(bContext *C, const char *filepath, int fileflags, ReportList *
 	/* don't forget not to return without! */
 	WM_cursor_wait(1);
 	
-	write_flush_editdata(C);
+	ED_editors_flush_edits(C, false);
 
 	fileflags |= G_FILE_HISTORY; /* write file history */
 
@@ -1019,7 +1003,7 @@ int wm_homefile_write_exec(bContext *C, wmOperator *op)
 	BLI_make_file_string("/", filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
 	printf("trying to save homefile at %s ", filepath);
 	
-	write_flush_editdata(C);
+	ED_editors_flush_edits(C, false);
 
 	/*  force save as regular blend file */
 	fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY);




More information about the Bf-blender-cvs mailing list