[Bf-blender-cvs] [639d512369d] soc-2020-io-performance: Support modifiers' render and viewport properties

Ankit Meel noreply at git.blender.org
Mon Jul 6 11:28:05 CEST 2020


Commit: 639d512369dc9c0a617c8436262ff3905a46a86b
Author: Ankit Meel
Date:   Mon Jul 6 14:07:20 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB639d512369dc9c0a617c8436262ff3905a46a86b

Support modifiers' render and viewport properties

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

M	source/blender/editors/io/io_obj.c
M	source/blender/io/wavefront_obj/IO_wavefront_obj.h
M	source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc

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

diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
index c6e7eda74f5..0f147a990f3 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -67,6 +67,19 @@ const EnumPropertyItem io_obj_transform_axis_up[] = {
     {OBJ_AXIS_NEGATIVE_Z_UP, "NEGATIVE_Z_UP", 0, "-Z", "Negative Z-axis"},
     {0, NULL, 0, NULL, NULL}};
 
+const EnumPropertyItem io_obj_export_evaluation_mode[] = {
+    {DAG_EVAL_RENDER,
+     "DAG_EVAL_RENDER",
+     0,
+     "Render properties",
+     "Modifiers need to be applied for render properties to take effect"},
+    {DAG_EVAL_VIEWPORT,
+     "DAG_EVAL_VIEWPORT",
+     0,
+     "Viewport properties (Default)",
+     "Export objects as they appear in the viewport"},
+    {0, NULL, 0, NULL, NULL}};
+
 static int wm_obj_export_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
 
@@ -106,6 +119,7 @@ static int wm_obj_export_exec(bContext *C, wmOperator *op)
   export_params.forward_axis = RNA_enum_get(op->ptr, "forward_axis");
   export_params.up_axis = RNA_enum_get(op->ptr, "up_axis");
   export_params.scaling_factor = RNA_float_get(op->ptr, "scaling_factor");
+  export_params.export_eval_mode = RNA_enum_get(op->ptr, "export_eval_mode");
 
   export_params.export_selected_objects = RNA_boolean_get(op->ptr, "export_selected_objects");
   export_params.export_uv = RNA_boolean_get(op->ptr, "export_uv");
@@ -162,6 +176,9 @@ static void ui_obj_export_settings(uiLayout *layout, PointerRNA *imfptr)
   row = uiLayoutRow(box, false);
   uiItemR(row, imfptr, "scaling_factor", 0, NULL, ICON_NONE);
 
+  row = uiLayoutRow(box, false);
+  uiItemR(row, imfptr, "export_eval_mode", 0, NULL, ICON_NONE);
+
   /* File write options. */
   box = uiLayoutBox(layout);
   row = uiLayoutRow(box, false);
@@ -311,6 +328,12 @@ void WM_OT_obj_export(struct wmOperatorType *ot)
                 0.01,
                 1000.000f);
   /* File Writer options. */
+  RNA_def_enum(ot->srna,
+               "export_eval_mode",
+               io_obj_export_evaluation_mode,
+               DAG_EVAL_VIEWPORT,
+               "Modifiers",
+               "Use modifiers' viewport or render properties");
   RNA_def_boolean(ot->srna,
                   "export_selected_objects",
                   false,
diff --git a/source/blender/io/wavefront_obj/IO_wavefront_obj.h b/source/blender/io/wavefront_obj/IO_wavefront_obj.h
index 937498a9067..bc1230fad3d 100644
--- a/source/blender/io/wavefront_obj/IO_wavefront_obj.h
+++ b/source/blender/io/wavefront_obj/IO_wavefront_obj.h
@@ -26,6 +26,7 @@
 
 #include "BKE_context.h"
 #include "BLI_path_util.h"
+#include "DEG_depsgraph.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -67,6 +68,7 @@ struct OBJExportParams {
 
   /** File Write Options. */
   bool export_selected_objects;
+  eEvaluationMode export_eval_mode;
   bool export_uv;
   bool export_normals;
   bool export_materials;
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
index 3de99d3f25a..38f8df27441 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
@@ -180,9 +180,11 @@ void exporter_main(bContext *C, const OBJExportParams &export_params)
    * https://hastebin.com/mitihetagi in file F8653460 */
   ED_object_editmode_exit(C, EM_FREEDATA);
   Scene *scene = CTX_data_scene(C);
-  Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
   Main *bmain = CTX_data_main(C);
   ViewLayer *view_layer = CTX_data_view_layer(C);
+  Depsgraph *depsgraph = export_params.export_eval_mode == DAG_EVAL_RENDER ?
+                             DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER) :
+                             CTX_data_ensure_evaluated_depsgraph(C);
   const char *filepath = export_params.filepath;
 
   /* Single frame export, i.e. no amimation is to be exported. */



More information about the Bf-blender-cvs mailing list