[Bf-blender-cvs] [7258cc7943f] soc-2019-fast-io: [Fast import/export] Initial skeleton

Hugo Sales noreply at git.blender.org
Wed May 22 13:40:03 CEST 2019


Commit: 7258cc7943fc404ab51d0044354b10bf3addf683
Author: Hugo Sales
Date:   Thu Feb 7 21:14:31 2019 +0000
Branches: soc-2019-fast-io
https://developer.blender.org/rB7258cc7943fc404ab51d0044354b10bf3addf683

[Fast import/export] Initial skeleton

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

M	.gitignore
M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/editors/io/CMakeLists.txt
A	source/blender/editors/io/intern/common.c
A	source/blender/editors/io/intern/common.h
A	source/blender/editors/io/intern/obj.cpp
A	source/blender/editors/io/intern/obj.h
A	source/blender/editors/io/io_common.c
A	source/blender/editors/io/io_common.h
A	source/blender/editors/io/io_obj.c
A	source/blender/editors/io/io_obj.h
M	source/blender/editors/io/io_ops.c

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

diff --git a/.gitignore b/.gitignore
index ef39eb5796c..8351661d16c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ Desktop.ini
 # commonly used paths in blender
 /blender.bin
 /BUILD_NOTES.txt
+build_files/build_environment/BUILD_NOTES.txt
 
 # local patches
 /*.patch
@@ -40,3 +41,10 @@ Desktop.ini
 
 # in-source lib downloads
 /build_files/build_environment/downloads
+
+# in-source GTAGS databases
+GPATH
+GRTAGS
+GTAGS
+
+CMakeFiles/
\ No newline at end of file
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 62488f9663f..01a7dd0346c 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -408,6 +408,8 @@ class TOPBAR_MT_file_import(Menu):
         if bpy.app.build_options.alembic:
             self.layout.operator("wm.alembic_import", text="Alembic (.abc)")
 
+        self.layout.operator("wm.obj_import", text="Wavefront (.obj)")
+
 
 class TOPBAR_MT_file_export(Menu):
     bl_idname = "TOPBAR_MT_file_export"
@@ -419,6 +421,7 @@ class TOPBAR_MT_file_export(Menu):
         if bpy.app.build_options.alembic:
             self.layout.operator("wm.alembic_export", text="Alembic (.abc)")
 
+        self.layout.operator("wm.obj_export", text="Wavefront (.obj)")
 
 class TOPBAR_MT_file_external_data(Menu):
     bl_label = "External Data"
diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt
index 5a35b251d0c..b968786359e 100644
--- a/source/blender/editors/io/CMakeLists.txt
+++ b/source/blender/editors/io/CMakeLists.txt
@@ -28,6 +28,7 @@ set(INC
   ../../makesrna
   ../../windowmanager
   ../../../../intern/guardedalloc
+  intern
 )
 
 set(INC_SYS
@@ -39,11 +40,20 @@ set(SRC
   io_cache.c
   io_collada.c
   io_ops.c
+  io_common.c
+  io_obj.c
 
   io_alembic.h
   io_cache.h
   io_collada.h
   io_ops.h
+  io_common.h
+  io_obj.h
+
+  intern/obj.cpp
+  intern/obj.h
+  intern/common.c
+  intern/common.h
 )
 
 set(LIB
diff --git a/source/blender/editors/io/intern/common.c b/source/blender/editors/io/intern/common.c
new file mode 100644
index 00000000000..cf95600844f
--- /dev/null
+++ b/source/blender/editors/io/intern/common.c
@@ -0,0 +1,67 @@
+#include "BLI_listbase.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_layer_types.h"
+#include "DNA_object_types.h"
+#include "DNA_modifier_types.h"
+
+#include "BKE_modifier.h"
+
+#include "../io_common.h"
+#include "common.h"
+
+/**
+ * Returns whether this object should be exported into the Alembic file.
+ *
+ * \param settings: export settings, used for options like 'selected only'.
+ * \param ob: the object's base in question.
+ * \param is_duplicated: Normally false; true when the object is instanced
+ * into the scene by a dupli-object (e.g. part of a dupligroup).
+ * This ignores selection and layer visibility,
+ * and assumes that the dupli-object itself (e.g. the group-instantiating empty) is exported.
+ */
+bool common_export_object_p(const ExportSettings * const settings, const Base * const ob_base,
+                             bool is_duplicated) {
+	if (!is_duplicated) {
+		/* These two tests only make sense when the object isn't being instanced
+		 * into the scene. When it is, its exportability is determined by
+		 * its dupli-object and the DupliObject::no_draw property. */
+		if (settings->selected_only && (ob_base->flag & BASE_SELECTED) != 0) {
+			return false;
+		}
+		// FIXME Sybren: handle these cleanly (maybe just remove code), now using active scene layer instead.
+		if (settings->visible_only && (ob_base->flag & BASE_VISIBLE) == 0) {
+			return false;
+		}
+
+		if (settings->renderable_only && (ob_base->flag & BASE_ENABLED_RENDER)) {
+			return false;
+		}
+	}
+
+	return true;
+}
+
+
+bool common_object_type_is_exportable(Scene *scene, Object *ob) {
+	switch (ob->type) {
+	case OB_MESH:
+		return !common_object_is_smoke_sim(ob);
+	case OB_EMPTY:
+	case OB_CURVE:
+	case OB_SURF:
+	case OB_CAMERA:
+		return true;
+	default:
+		return false;
+	}
+}
+
+static bool common_object_is_smoke_sim(Object *ob) {
+	ModifierData *md = modifiers_findByType(ob, eModifierType_Smoke);
+	if (md) {
+		SmokeModifierData *smd = md;
+		return (smd->type == MOD_SMOKE_TYPE_DOMAIN);
+	}
+	return false;
+}
diff --git a/source/blender/editors/io/intern/common.h b/source/blender/editors/io/intern/common.h
new file mode 100644
index 00000000000..8a456eaca0b
--- /dev/null
+++ b/source/blender/editors/io/intern/common.h
@@ -0,0 +1,17 @@
+/* #include "BLI_listbase.h" */
+
+/* #include "DNA_mesh_types.h" */
+/* #include "DNA_object_types.h" */
+
+#include "DNA_layer_types.h"
+
+#include "../io_common.h"
+
+bool common_export_object_p(const ExportSettings * const settings, const Base * const ob_base,
+                             bool is_duplicated);
+
+
+bool common_object_type_is_exportable(Scene *scene, Object *ob);
+
+
+static bool common_object_is_smoke_sim(Object *ob);
diff --git a/source/blender/editors/io/intern/obj.cpp b/source/blender/editors/io/intern/obj.cpp
new file mode 100644
index 00000000000..608144f02d3
--- /dev/null
+++ b/source/blender/editors/io/intern/obj.cpp
@@ -0,0 +1,74 @@
+extern "C" {
+
+#include "BKE_global.h"
+#include "BKE_context.h"
+#include "BKE_scene.h"
+/* SpaceType struct has a member called 'new' which obviously conflicts with C++
+ * so temporarily redefining the new keyword to make it compile. */
+#define new extern_new
+#include "BKE_screen.h"
+#undef new
+
+#include "DNA_space_types.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "obj.h"
+#include "../io_common.h"
+#include "common.h"
+
+}
+
+bool OBJ_export(bContext *C, ExportSettings *settings) {
+
+	OBJ_export_start(C, settings);
+	return OBJ_export_end(C, settings);
+}
+
+bool OBJ_export_start(bContext *C, ExportSettings *settings) {
+	/* From alembic_capi.cc
+	 * XXX annoying hack: needed to prevent data corruption when changing
+	 * scene frame in separate threads
+	 */
+	G.is_rendering = true;
+	BKE_spacedata_draw_locks(true);
+
+	DEG_graph_build_from_view_layer(settings->depsgraph,
+	                                CTX_data_main(C),
+	                                settings->scene,
+	                                settings->view_layer);
+	BKE_scene_graph_update_tagged(settings->depsgraph, CTX_data_main(C));
+
+	for (Base *base = static_cast<Base *>(settings->view_layer->object_bases.first); base; base = base->next) {
+		Object *ob = base->object;
+		if (common_export_object_p(settings, base, false)) {
+			Object *eob = DEG_get_evaluated_object(settings->depsgraph, ob);
+			if (common_object_type_is_exportable(settings->scene, eob)) {
+				// createTransformWriter(ob, parent, dupliObParent);
+			}
+
+		}
+	}
+
+	G.is_break = false;
+	return true;
+}
+
+bool OBJ_export_end(bContext *UNUSED(C), ExportSettings *settings) {
+	G.is_rendering = false;
+	BKE_spacedata_draw_locks(false);
+
+	MEM_freeN(settings);
+	return true;
+}
+
+// void io_obj_write_object() {
+
+// }
diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/intern/obj.h
similarity index 51%
copy from source/blender/editors/io/io_ops.c
copy to source/blender/editors/io/intern/obj.h
index e04fe4a20c0..44d3fd905f5 100644
--- a/source/blender/editors/io/io_ops.c
+++ b/source/blender/editors/io/intern/obj.h
@@ -1,4 +1,6 @@
 /*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -13,40 +15,30 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2008 Blender Foundation.
- * All rights reserved.
+ * Contributor(s): Hugo Sales
+ *
+ * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file
- * \ingroup collada
- */
+/* #ifndef __IO_OBJ_H__ */
+/* #define __IO_OBJ_H__ */
 
-#include "io_ops.h" /* own include */
+#ifdef __cplusplus
+extern "C" {
+#endif  /* __cplusplus */
 
-#include "WM_api.h"
+#include "../io_common.h"
 
-#ifdef WITH_COLLADA
-#  include "io_collada.h"
-#endif
 
-#ifdef WITH_ALEMBIC
-#  include "io_alembic.h"
-#endif
+struct bContext;
 
-#include "io_cache.h"
+bool OBJ_export(bContext *C, ExportSettings *settings);
+bool OBJ_export_start(bContext *C, ExportSettings *settings);
+bool OBJ_export_end(bContext *C, ExportSettings *settings);
 
-void ED_operatortypes_io(void)
-{
-#ifdef WITH_COLLADA
-  /* Collada operators: */
-  WM_operatortype_append(WM_OT_collada_export);
-  WM_operatortype_append(WM_OT_collada_import);
-#endif
-#ifdef WITH_ALEMBIC
-  WM_operatortype_append(WM_OT_alembic_import);
-  WM_operatortype_append(WM_OT_alembic_export);
-#endif
 
-  WM_operatortype_append(CACHEFILE_OT_open);
-  WM_operatortype_append(CACHEFILE_OT_reload);
+#ifdef __cplusplus
 }
+#endif  /* __cplusplus */
+
+/* #endif  /\* __IO_OBJ_H__ *\/ */
diff --git a/source/blender/editors/io/io_common.c b/source/blender/editors/io/io_common.c
new file mode 100644
index 00000000000..3a6e9496084
--- /dev/null
+++ b/source/blender/editors/io/io_common.c
@@ -0,0 +1,213 @@
+#include "io_common.h"
+
+#include "DNA_modifier_types.h"
+
+#include "BLI_string.h"
+#include "BLI_path_util.h"
+
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
+#include "MEM_guardedalloc.h"
+
+void io_common_default_declare_export(struct wmOperatorType *ot,
+                                      eFileSel_File_Types file_type) {
+
+	WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER | file_type,
+	                               FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH,
+	                               FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA);
+
+	RNA_def_boolean(ot->srna, "selected_only", 0,
+	                "Selected Objects Only", "Export only selected 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list