[Bf-blender-cvs] [42a8ea1af3b] soc-2020-io-performance: Remove object filtering code from export_frame.

Ankit Meel noreply at git.blender.org
Thu Jul 2 10:15:51 CEST 2020


Commit: 42a8ea1af3bcb7dfa22a5fce6afad6e2e959285d
Author: Ankit Meel
Date:   Thu Jul 2 13:45:44 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB42a8ea1af3bcb7dfa22a5fce6afad6e2e959285d

Remove object filtering code from export_frame.

Also return early if the file cannot be opened before looping over all
the objects in a frame.

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

M	source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc

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

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 97af6859c17..2cc5d1b51b7 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
@@ -45,12 +45,14 @@ namespace io {
 namespace obj {
 
 /**
- * Traverses over and exports a single frame to a single OBJ file.
+ * Scan objects in a scene to find exportable objects, as per export_params and object types, and
+ * add them to the given Vectors.
  */
-static void export_frame(bContext *C, const OBJExportParams *export_params, const char *filepath)
+static void filter_exportable_objects(bContext *C,
+                                      const OBJExportParams *export_params,
+                                      Vector<std::unique_ptr<OBJMesh>> &exportable_meshes,
+                                      Vector<std::unique_ptr<OBJNurbs>> &exportable_nurbs)
 {
-  Vector<std::unique_ptr<OBJMesh>> exportable_meshes;
-  Vector<std::unique_ptr<OBJNurbs>> exportable_nurbs;
   ViewLayer *view_layer = CTX_data_view_layer(C);
   LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
     Object *object_in_layer = base->object;
@@ -88,13 +90,23 @@ static void export_frame(bContext *C, const OBJExportParams *export_params, cons
         break;
     }
   }
+}
 
+/**
+ * Traverses over and exports a single frame to a single OBJ file.
+ */
+static void export_frame(bContext *C, const OBJExportParams *export_params, const char *filepath)
+{
   OBJWriter frame_writer(export_params);
   if (!frame_writer.init_writer()) {
     fprintf(stderr, "Error in creating the file: %s\n", export_params->filepath);
     return;
   }
 
+  Vector<std::unique_ptr<OBJMesh>> exportable_meshes;
+  Vector<std::unique_ptr<OBJNurbs>> exportable_nurbs;
+  filter_exportable_objects(C, export_params, exportable_meshes, exportable_nurbs);
+
   if (export_params->export_materials) {
     /* Write MTL filename to the OBJ file. Also create an empty MTL file of the same name as the
      * OBJ. */



More information about the Bf-blender-cvs mailing list