Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-06-19 14:45:34 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-06-19 16:30:18 +0300
commit89b7f785e64275819bd7372f6b47f1cc9225078f (patch)
tree00dd07b464df774da5d8d2290192be74dd4511ee /source/blender
parent16d09a5864069c3d84988ba300a4785457a531ab (diff)
Cleanup: Alembic, moved exporter code into separate directory
This moves most of the exporter-related code from `source/blender/io/alembic/intern` to `source/blender/io/alembic/exporter` This is to prepare the Alembic code for the switchover to using `blender::io::AbstractHierarchyIterator`. When that happens, a few more files will be added, and having things in a separate 'exporter' directory makes things less cluttered. Note that exporting consists of multiple steps (determine export hierarchy, create Alembic archive, and then write data into it), which is why the directory is called "exporter", but many of the files are called "writer". No functional changes.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/io/alembic/CMakeLists.txt47
-rw-r--r--source/blender/io/alembic/exporter/abc_export_capi.cc239
-rw-r--r--source/blender/io/alembic/exporter/abc_exporter.cc (renamed from source/blender/io/alembic/intern/abc_exporter.cc)2
-rw-r--r--source/blender/io/alembic/exporter/abc_exporter.h (renamed from source/blender/io/alembic/intern/abc_exporter.h)2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_archive.cc (renamed from source/blender/io/alembic/intern/abc_writer_archive.cc)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_archive.h (renamed from source/blender/io/alembic/intern/abc_writer_archive.h)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_camera.cc (renamed from source/blender/io/alembic/intern/abc_writer_camera.cc)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_camera.h (renamed from source/blender/io/alembic/intern/abc_writer_camera.h)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_curves.cc (renamed from source/blender/io/alembic/intern/abc_writer_curves.cc)4
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_curves.h (renamed from source/blender/io/alembic/intern/abc_writer_curves.h)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_hair.cc (renamed from source/blender/io/alembic/intern/abc_writer_hair.cc)2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_hair.h (renamed from source/blender/io/alembic/intern/abc_writer_hair.h)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_mball.cc (renamed from source/blender/io/alembic/intern/abc_writer_mball.cc)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_mball.h (renamed from source/blender/io/alembic/intern/abc_writer_mball.h)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_mesh.cc (renamed from source/blender/io/alembic/intern/abc_writer_mesh.cc)2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_mesh.h (renamed from source/blender/io/alembic/intern/abc_writer_mesh.h)2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_nurbs.cc (renamed from source/blender/io/alembic/intern/abc_writer_nurbs.cc)2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_nurbs.h (renamed from source/blender/io/alembic/intern/abc_writer_nurbs.h)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_object.cc (renamed from source/blender/io/alembic/intern/abc_writer_object.cc)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_object.h (renamed from source/blender/io/alembic/intern/abc_writer_object.h)0
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_points.cc (renamed from source/blender/io/alembic/intern/abc_writer_points.cc)2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_points.h (renamed from source/blender/io/alembic/intern/abc_writer_points.h)2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_transform.cc (renamed from source/blender/io/alembic/intern/abc_writer_transform.cc)2
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_transform.h (renamed from source/blender/io/alembic/intern/abc_writer_transform.h)0
-rw-r--r--source/blender/io/alembic/intern/alembic_capi.cc196
25 files changed, 275 insertions, 229 deletions
diff --git a/source/blender/io/alembic/CMakeLists.txt b/source/blender/io/alembic/CMakeLists.txt
index d864aa51e64..c0c91099ad2 100644
--- a/source/blender/io/alembic/CMakeLists.txt
+++ b/source/blender/io/alembic/CMakeLists.txt
@@ -43,7 +43,6 @@ set(INC_SYS
set(SRC
intern/abc_axis_conversion.cc
intern/abc_customdata.cc
- intern/abc_exporter.cc
intern/abc_reader_archive.cc
intern/abc_reader_camera.cc
intern/abc_reader_curves.cc
@@ -53,22 +52,24 @@ set(SRC
intern/abc_reader_points.cc
intern/abc_reader_transform.cc
intern/abc_util.cc
- intern/abc_writer_archive.cc
- intern/abc_writer_camera.cc
- intern/abc_writer_curves.cc
- intern/abc_writer_hair.cc
- intern/abc_writer_mball.cc
- intern/abc_writer_mesh.cc
- intern/abc_writer_nurbs.cc
- intern/abc_writer_object.cc
- intern/abc_writer_points.cc
- intern/abc_writer_transform.cc
intern/alembic_capi.cc
+ exporter/abc_export_capi.cc
+ exporter/abc_exporter.cc
+ exporter/abc_writer_archive.cc
+ exporter/abc_writer_camera.cc
+ exporter/abc_writer_curves.cc
+ exporter/abc_writer_hair.cc
+ exporter/abc_writer_mball.cc
+ exporter/abc_writer_mesh.cc
+ exporter/abc_writer_nurbs.cc
+ exporter/abc_writer_object.cc
+ exporter/abc_writer_points.cc
+ exporter/abc_writer_transform.cc
+
ABC_alembic.h
intern/abc_axis_conversion.h
intern/abc_customdata.h
- intern/abc_exporter.h
intern/abc_reader_archive.h
intern/abc_reader_camera.h
intern/abc_reader_curves.h
@@ -78,16 +79,18 @@ set(SRC
intern/abc_reader_points.h
intern/abc_reader_transform.h
intern/abc_util.h
- intern/abc_writer_archive.h
- intern/abc_writer_camera.h
- intern/abc_writer_curves.h
- intern/abc_writer_hair.h
- intern/abc_writer_mball.h
- intern/abc_writer_mesh.h
- intern/abc_writer_nurbs.h
- intern/abc_writer_object.h
- intern/abc_writer_points.h
- intern/abc_writer_transform.h
+
+ exporter/abc_exporter.h
+ exporter/abc_writer_archive.h
+ exporter/abc_writer_camera.h
+ exporter/abc_writer_curves.h
+ exporter/abc_writer_hair.h
+ exporter/abc_writer_mball.h
+ exporter/abc_writer_mesh.h
+ exporter/abc_writer_nurbs.h
+ exporter/abc_writer_object.h
+ exporter/abc_writer_points.h
+ exporter/abc_writer_transform.h
)
set(LIB
diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc
new file mode 100644
index 00000000000..3f8e95a6128
--- /dev/null
+++ b/source/blender/io/alembic/exporter/abc_export_capi.cc
@@ -0,0 +1,239 @@
+/*
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+#include "ABC_alembic.h"
+#include "abc_writer_camera.h"
+#include "abc_writer_curves.h"
+#include "abc_writer_hair.h"
+#include "abc_writer_mesh.h"
+#include "abc_writer_nurbs.h"
+#include "abc_writer_points.h"
+#include "abc_writer_transform.h"
+
+#include "MEM_guardedalloc.h"
+
+extern "C" {
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
+#include "DNA_modifier_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_blender_version.h"
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_scene.h"
+
+#include "BLI_fileops.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+}
+
+struct ExportJobData {
+ ViewLayer *view_layer;
+ Main *bmain;
+ wmWindowManager *wm;
+
+ char filename[1024];
+ ExportSettings settings;
+
+ short *stop;
+ short *do_update;
+ float *progress;
+
+ bool was_canceled;
+ bool export_ok;
+};
+
+static void export_startjob(void *customdata, short *stop, short *do_update, float *progress)
+{
+ ExportJobData *data = static_cast<ExportJobData *>(customdata);
+
+ data->stop = stop;
+ data->do_update = do_update;
+ data->progress = progress;
+
+ /* XXX annoying hack: needed to prevent data corruption when changing
+ * scene frame in separate threads
+ */
+ G.is_rendering = true;
+ WM_set_locked_interface(data->wm, true);
+ G.is_break = false;
+
+ DEG_graph_build_from_view_layer(
+ data->settings.depsgraph, data->bmain, data->settings.scene, data->view_layer);
+ BKE_scene_graph_update_tagged(data->settings.depsgraph, data->bmain);
+
+ try {
+ AbcExporter exporter(data->bmain, data->filename, data->settings);
+
+ Scene *scene = data->settings.scene; /* for the CFRA macro */
+ const int orig_frame = CFRA;
+
+ data->was_canceled = false;
+ exporter(do_update, progress, &data->was_canceled);
+
+ if (CFRA != orig_frame) {
+ CFRA = orig_frame;
+
+ BKE_scene_graph_update_for_newframe(data->settings.depsgraph, data->bmain);
+ }
+
+ data->export_ok = !data->was_canceled;
+ }
+ catch (const std::exception &e) {
+ ABC_LOG(data->settings.logger) << "Abc Export error: " << e.what() << '\n';
+ }
+ catch (...) {
+ ABC_LOG(data->settings.logger) << "Abc Export: unknown error...\n";
+ }
+}
+
+static void export_endjob(void *customdata)
+{
+ ExportJobData *data = static_cast<ExportJobData *>(customdata);
+
+ DEG_graph_free(data->settings.depsgraph);
+
+ if (data->was_canceled && BLI_exists(data->filename)) {
+ BLI_delete(data->filename, false, false);
+ }
+
+ std::string log = data->settings.logger.str();
+ if (!log.empty()) {
+ std::cerr << log;
+ WM_report(RPT_ERROR, "Errors occurred during the export, look in the console to know more...");
+ }
+
+ G.is_rendering = false;
+ WM_set_locked_interface(data->wm, false);
+}
+
+bool ABC_export(struct Scene *scene,
+ struct bContext *C,
+ const char *filepath,
+ const struct AlembicExportParams *params,
+ bool as_background_job)
+{
+ ExportJobData *job = static_cast<ExportJobData *>(
+ MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
+
+ job->view_layer = CTX_data_view_layer(C);
+ job->bmain = CTX_data_main(C);
+ job->wm = CTX_wm_manager(C);
+ job->export_ok = false;
+ BLI_strncpy(job->filename, filepath, 1024);
+
+ /* Alright, alright, alright....
+ *
+ * ExportJobData contains an ExportSettings containing a SimpleLogger.
+ *
+ * Since ExportJobData is a C-style struct dynamically allocated with
+ * MEM_mallocN (see above), its constructor is never called, therefore the
+ * ExportSettings constructor is not called which implies that the
+ * SimpleLogger one is not called either. SimpleLogger in turn does not call
+ * the constructor of its data members which ultimately means that its
+ * std::ostringstream member has a NULL pointer. To be able to properly use
+ * the stream's operator<<, the pointer needs to be set, therefore we have
+ * to properly construct everything. And this is done using the placement
+ * new operator as here below. It seems hackish, but I'm too lazy to
+ * do bigger refactor and maybe there is a better way which does not involve
+ * hardcore refactoring. */
+ new (&job->settings) ExportSettings();
+ job->settings.scene = scene;
+ job->settings.depsgraph = DEG_graph_new(job->bmain, scene, job->view_layer, DAG_EVAL_RENDER);
+
+ /* TODO(Sybren): for now we only export the active scene layer.
+ * Later in the 2.8 development process this may be replaced by using
+ * a specific collection for Alembic I/O, which can then be toggled
+ * between "real" objects and cached Alembic files. */
+ job->settings.view_layer = job->view_layer;
+
+ job->settings.frame_start = params->frame_start;
+ job->settings.frame_end = params->frame_end;
+ job->settings.frame_samples_xform = params->frame_samples_xform;
+ job->settings.frame_samples_shape = params->frame_samples_shape;
+ job->settings.shutter_open = params->shutter_open;
+ job->settings.shutter_close = params->shutter_close;
+
+ /* TODO(Sybren): For now this is ignored, until we can get selection
+ * detection working through Base pointers (instead of ob->flags). */
+ job->settings.selected_only = params->selected_only;
+
+ job->settings.export_face_sets = params->face_sets;
+ job->settings.export_normals = params->normals;
+ job->settings.export_uvs = params->uvs;
+ job->settings.export_vcols = params->vcolors;
+ job->settings.export_hair = params->export_hair;
+ job->settings.export_particles = params->export_particles;
+ job->settings.apply_subdiv = params->apply_subdiv;
+ job->settings.curves_as_mesh = params->curves_as_mesh;
+ job->settings.flatten_hierarchy = params->flatten_hierarchy;
+
+ /* TODO(Sybren): visible_layer & renderable only is ignored for now,
+ * to be replaced with collections later in the 2.8 dev process
+ * (also see note above). */
+ job->settings.visible_objects_only = params->visible_objects_only;
+ job->settings.renderable_only = params->renderable_only;
+
+ job->settings.use_subdiv_schema = params->use_subdiv_schema;
+ job->settings.pack_uv = params->packuv;
+ job->settings.global_scale = params->global_scale;
+ job->settings.triangulate = params->triangulate;
+ job->settings.quad_method = params->quad_method;
+ job->settings.ngon_method = params->ngon_method;
+
+ if (job->settings.frame_start > job->settings.frame_end) {
+ std::swap(job->settings.frame_start, job->settings.frame_end);
+ }
+
+ bool export_ok = false;
+ if (as_background_job) {
+ wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
+ CTX_wm_window(C),
+ job->settings.scene,
+ "Alembic Export",
+ WM_JOB_PROGRESS,
+ WM_JOB_TYPE_ALEMBIC);
+
+ /* setup job */
+ WM_jobs_customdata_set(wm_job, job, MEM_freeN);
+ WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_FRAME, NC_SCENE | ND_FRAME);
+ WM_jobs_callbacks(wm_job, export_startjob, NULL, NULL, export_endjob);
+
+ WM_jobs_start(CTX_wm_manager(C), wm_job);
+ }
+ else {
+ /* Fake a job context, so that we don't need NULL pointer checks while exporting. */
+ short stop = 0, do_update = 0;
+ float progress = 0.f;
+
+ export_startjob(job, &stop, &do_update, &progress);
+ export_endjob(job);
+ export_ok = job->export_ok;
+
+ MEM_freeN(job);
+ }
+
+ return export_ok;
+}
diff --git a/source/blender/io/alembic/intern/abc_exporter.cc b/source/blender/io/alembic/exporter/abc_exporter.cc
index 8dad8dff199..0de6c393e5a 100644
--- a/source/blender/io/alembic/intern/abc_exporter.cc
+++ b/source/blender/io/alembic/exporter/abc_exporter.cc
@@ -22,7 +22,6 @@
#include <cmath>
-#include "abc_util.h"
#include "abc_writer_archive.h"
#include "abc_writer_camera.h"
#include "abc_writer_curves.h"
@@ -32,6 +31,7 @@
#include "abc_writer_nurbs.h"
#include "abc_writer_points.h"
#include "abc_writer_transform.h"
+#include "intern/abc_util.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
diff --git a/source/blender/io/alembic/intern/abc_exporter.h b/source/blender/io/alembic/exporter/abc_exporter.h
index 049ccb291bd..c1c54cb2208 100644
--- a/source/blender/io/alembic/intern/abc_exporter.h
+++ b/source/blender/io/alembic/exporter/abc_exporter.h
@@ -26,7 +26,7 @@
#include <set>
#include <vector>
-#include "abc_util.h"
+#include "intern/abc_util.h"
class AbcObjectWriter;
class AbcTransformWriter;
diff --git a/source/blender/io/alembic/intern/abc_writer_archive.cc b/source/blender/io/alembic/exporter/abc_writer_archive.cc
index 40926532f85..40926532f85 100644
--- a/source/blender/io/alembic/intern/abc_writer_archive.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_archive.cc
diff --git a/source/blender/io/alembic/intern/abc_writer_archive.h b/source/blender/io/alembic/exporter/abc_writer_archive.h
index 737717c1710..737717c1710 100644
--- a/source/blender/io/alembic/intern/abc_writer_archive.h
+++ b/source/blender/io/alembic/exporter/abc_writer_archive.h
diff --git a/source/blender/io/alembic/intern/abc_writer_camera.cc b/source/blender/io/alembic/exporter/abc_writer_camera.cc
index 07ae81e584f..07ae81e584f 100644
--- a/source/blender/io/alembic/intern/abc_writer_camera.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_camera.cc
diff --git a/source/blender/io/alembic/intern/abc_writer_camera.h b/source/blender/io/alembic/exporter/abc_writer_camera.h
index 3b515911a48..3b515911a48 100644
--- a/source/blender/io/alembic/intern/abc_writer_camera.h
+++ b/source/blender/io/alembic/exporter/abc_writer_camera.h
diff --git a/source/blender/io/alembic/intern/abc_writer_curves.cc b/source/blender/io/alembic/exporter/abc_writer_curves.cc
index db93ac1920e..3f9a53cffc6 100644
--- a/source/blender/io/alembic/intern/abc_writer_curves.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_curves.cc
@@ -22,9 +22,9 @@
*/
#include "abc_writer_curves.h"
-#include "abc_axis_conversion.h"
-#include "abc_reader_curves.h"
#include "abc_writer_transform.h"
+#include "intern/abc_axis_conversion.h"
+#include "intern/abc_reader_curves.h"
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
diff --git a/source/blender/io/alembic/intern/abc_writer_curves.h b/source/blender/io/alembic/exporter/abc_writer_curves.h
index 83f0289dd2d..83f0289dd2d 100644
--- a/source/blender/io/alembic/intern/abc_writer_curves.h
+++ b/source/blender/io/alembic/exporter/abc_writer_curves.h
diff --git a/source/blender/io/alembic/intern/abc_writer_hair.cc b/source/blender/io/alembic/exporter/abc_writer_hair.cc
index 43c05627130..ceb2eb7d316 100644
--- a/source/blender/io/alembic/intern/abc_writer_hair.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_hair.cc
@@ -19,8 +19,8 @@
*/
#include "abc_writer_hair.h"
-#include "abc_axis_conversion.h"
#include "abc_writer_transform.h"
+#include "intern/abc_axis_conversion.h"
#include <cstdio>
diff --git a/source/blender/io/alembic/intern/abc_writer_hair.h b/source/blender/io/alembic/exporter/abc_writer_hair.h
index 67d1b7b3d23..67d1b7b3d23 100644
--- a/source/blender/io/alembic/intern/abc_writer_hair.h
+++ b/source/blender/io/alembic/exporter/abc_writer_hair.h
diff --git a/source/blender/io/alembic/intern/abc_writer_mball.cc b/source/blender/io/alembic/exporter/abc_writer_mball.cc
index 3593acf18b0..3593acf18b0 100644
--- a/source/blender/io/alembic/intern/abc_writer_mball.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_mball.cc
diff --git a/source/blender/io/alembic/intern/abc_writer_mball.h b/source/blender/io/alembic/exporter/abc_writer_mball.h
index e3ac1e69cae..e3ac1e69cae 100644
--- a/source/blender/io/alembic/intern/abc_writer_mball.h
+++ b/source/blender/io/alembic/exporter/abc_writer_mball.h
diff --git a/source/blender/io/alembic/intern/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc
index df1734c9de1..b17e123b426 100644
--- a/source/blender/io/alembic/intern/abc_writer_mesh.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc
@@ -19,8 +19,8 @@
*/
#include "abc_writer_mesh.h"
-#include "abc_axis_conversion.h"
#include "abc_writer_transform.h"
+#include "intern/abc_axis_conversion.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
diff --git a/source/blender/io/alembic/intern/abc_writer_mesh.h b/source/blender/io/alembic/exporter/abc_writer_mesh.h
index 9152a370e4f..264696333a3 100644
--- a/source/blender/io/alembic/intern/abc_writer_mesh.h
+++ b/source/blender/io/alembic/exporter/abc_writer_mesh.h
@@ -21,8 +21,8 @@
#ifndef __ABC_WRITER_MESH_H__
#define __ABC_WRITER_MESH_H__
-#include "abc_customdata.h"
#include "abc_writer_object.h"
+#include "intern/abc_customdata.h"
struct Mesh;
struct ModifierData;
diff --git a/source/blender/io/alembic/intern/abc_writer_nurbs.cc b/source/blender/io/alembic/exporter/abc_writer_nurbs.cc
index 8b4a1050d33..c856f894f0e 100644
--- a/source/blender/io/alembic/intern/abc_writer_nurbs.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_nurbs.cc
@@ -19,8 +19,8 @@
*/
#include "abc_writer_nurbs.h"
-#include "abc_axis_conversion.h"
#include "abc_writer_transform.h"
+#include "intern/abc_axis_conversion.h"
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
diff --git a/source/blender/io/alembic/intern/abc_writer_nurbs.h b/source/blender/io/alembic/exporter/abc_writer_nurbs.h
index c6a3c399b66..c6a3c399b66 100644
--- a/source/blender/io/alembic/intern/abc_writer_nurbs.h
+++ b/source/blender/io/alembic/exporter/abc_writer_nurbs.h
diff --git a/source/blender/io/alembic/intern/abc_writer_object.cc b/source/blender/io/alembic/exporter/abc_writer_object.cc
index 3d280d9f0a4..3d280d9f0a4 100644
--- a/source/blender/io/alembic/intern/abc_writer_object.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_object.cc
diff --git a/source/blender/io/alembic/intern/abc_writer_object.h b/source/blender/io/alembic/exporter/abc_writer_object.h
index 830c4aee903..830c4aee903 100644
--- a/source/blender/io/alembic/intern/abc_writer_object.h
+++ b/source/blender/io/alembic/exporter/abc_writer_object.h
diff --git a/source/blender/io/alembic/intern/abc_writer_points.cc b/source/blender/io/alembic/exporter/abc_writer_points.cc
index 6be4bcfdbe7..27f51586f47 100644
--- a/source/blender/io/alembic/intern/abc_writer_points.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_points.cc
@@ -22,9 +22,9 @@
*/
#include "abc_writer_points.h"
-#include "abc_util.h"
#include "abc_writer_mesh.h"
#include "abc_writer_transform.h"
+#include "intern/abc_util.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
diff --git a/source/blender/io/alembic/intern/abc_writer_points.h b/source/blender/io/alembic/exporter/abc_writer_points.h
index 184a363ae6b..e5c1b81f266 100644
--- a/source/blender/io/alembic/intern/abc_writer_points.h
+++ b/source/blender/io/alembic/exporter/abc_writer_points.h
@@ -24,8 +24,8 @@
#ifndef __ABC_WRITER_POINTS_H__
#define __ABC_WRITER_POINTS_H__
-#include "abc_customdata.h"
#include "abc_writer_object.h"
+#include "intern/abc_customdata.h"
struct ParticleSystem;
diff --git a/source/blender/io/alembic/intern/abc_writer_transform.cc b/source/blender/io/alembic/exporter/abc_writer_transform.cc
index ef3e7e29db2..46130cb8675 100644
--- a/source/blender/io/alembic/intern/abc_writer_transform.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_transform.cc
@@ -19,7 +19,7 @@
*/
#include "abc_writer_transform.h"
-#include "abc_axis_conversion.h"
+#include "intern/abc_axis_conversion.h"
#include <OpenEXR/ImathBoxAlgo.h>
diff --git a/source/blender/io/alembic/intern/abc_writer_transform.h b/source/blender/io/alembic/exporter/abc_writer_transform.h
index 4397b220761..4397b220761 100644
--- a/source/blender/io/alembic/intern/abc_writer_transform.h
+++ b/source/blender/io/alembic/exporter/abc_writer_transform.h
diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc
index a30b15fee5f..e70f19fdbd8 100644
--- a/source/blender/io/alembic/intern/alembic_capi.cc
+++ b/source/blender/io/alembic/intern/alembic_capi.cc
@@ -30,13 +30,6 @@
#include "abc_reader_points.h"
#include "abc_reader_transform.h"
#include "abc_util.h"
-#include "abc_writer_camera.h"
-#include "abc_writer_curves.h"
-#include "abc_writer_hair.h"
-#include "abc_writer_mesh.h"
-#include "abc_writer_nurbs.h"
-#include "abc_writer_points.h"
-#include "abc_writer_transform.h"
#include "MEM_guardedalloc.h"
@@ -225,195 +218,6 @@ static void find_iobject(const IObject &object, IObject &ret, const std::string
ret = tmp;
}
-struct ExportJobData {
- ViewLayer *view_layer;
- Main *bmain;
- wmWindowManager *wm;
-
- char filename[1024];
- ExportSettings settings;
-
- short *stop;
- short *do_update;
- float *progress;
-
- bool was_canceled;
- bool export_ok;
-};
-
-static void export_startjob(void *customdata, short *stop, short *do_update, float *progress)
-{
- ExportJobData *data = static_cast<ExportJobData *>(customdata);
-
- data->stop = stop;
- data->do_update = do_update;
- data->progress = progress;
-
- /* XXX annoying hack: needed to prevent data corruption when changing
- * scene frame in separate threads
- */
- G.is_rendering = true;
- WM_set_locked_interface(data->wm, true);
- G.is_break = false;
-
- DEG_graph_build_from_view_layer(
- data->settings.depsgraph, data->bmain, data->settings.scene, data->view_layer);
- BKE_scene_graph_update_tagged(data->settings.depsgraph, data->bmain);
-
- try {
- AbcExporter exporter(data->bmain, data->filename, data->settings);
-
- Scene *scene = data->settings.scene; /* for the CFRA macro */
- const int orig_frame = CFRA;
-
- data->was_canceled = false;
- exporter(do_update, progress, &data->was_canceled);
-
- if (CFRA != orig_frame) {
- CFRA = orig_frame;
-
- BKE_scene_graph_update_for_newframe(data->settings.depsgraph, data->bmain);
- }
-
- data->export_ok = !data->was_canceled;
- }
- catch (const std::exception &e) {
- ABC_LOG(data->settings.logger) << "Abc Export error: " << e.what() << '\n';
- }
- catch (...) {
- ABC_LOG(data->settings.logger) << "Abc Export: unknown error...\n";
- }
-}
-
-static void export_endjob(void *customdata)
-{
- ExportJobData *data = static_cast<ExportJobData *>(customdata);
-
- DEG_graph_free(data->settings.depsgraph);
-
- if (data->was_canceled && BLI_exists(data->filename)) {
- BLI_delete(data->filename, false, false);
- }
-
- std::string log = data->settings.logger.str();
- if (!log.empty()) {
- std::cerr << log;
- WM_report(RPT_ERROR, "Errors occurred during the export, look in the console to know more...");
- }
-
- G.is_rendering = false;
- WM_set_locked_interface(data->wm, false);
-}
-
-bool ABC_export(Scene *scene,
- bContext *C,
- const char *filepath,
- const struct AlembicExportParams *params,
- bool as_background_job)
-{
- ExportJobData *job = static_cast<ExportJobData *>(
- MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
-
- job->view_layer = CTX_data_view_layer(C);
- job->bmain = CTX_data_main(C);
- job->wm = CTX_wm_manager(C);
- job->export_ok = false;
- BLI_strncpy(job->filename, filepath, 1024);
-
- /* Alright, alright, alright....
- *
- * ExportJobData contains an ExportSettings containing a SimpleLogger.
- *
- * Since ExportJobData is a C-style struct dynamically allocated with
- * MEM_mallocN (see above), its constructor is never called, therefore the
- * ExportSettings constructor is not called which implies that the
- * SimpleLogger one is not called either. SimpleLogger in turn does not call
- * the constructor of its data members which ultimately means that its
- * std::ostringstream member has a NULL pointer. To be able to properly use
- * the stream's operator<<, the pointer needs to be set, therefore we have
- * to properly construct everything. And this is done using the placement
- * new operator as here below. It seems hackish, but I'm too lazy to
- * do bigger refactor and maybe there is a better way which does not involve
- * hardcore refactoring. */
- new (&job->settings) ExportSettings();
- job->settings.scene = scene;
- job->settings.depsgraph = DEG_graph_new(job->bmain, scene, job->view_layer, DAG_EVAL_RENDER);
-
- /* TODO(Sybren): for now we only export the active scene layer.
- * Later in the 2.8 development process this may be replaced by using
- * a specific collection for Alembic I/O, which can then be toggled
- * between "real" objects and cached Alembic files. */
- job->settings.view_layer = job->view_layer;
-
- job->settings.frame_start = params->frame_start;
- job->settings.frame_end = params->frame_end;
- job->settings.frame_samples_xform = params->frame_samples_xform;
- job->settings.frame_samples_shape = params->frame_samples_shape;
- job->settings.shutter_open = params->shutter_open;
- job->settings.shutter_close = params->shutter_close;
-
- /* TODO(Sybren): For now this is ignored, until we can get selection
- * detection working through Base pointers (instead of ob->flags). */
- job->settings.selected_only = params->selected_only;
-
- job->settings.export_face_sets = params->face_sets;
- job->settings.export_normals = params->normals;
- job->settings.export_uvs = params->uvs;
- job->settings.export_vcols = params->vcolors;
- job->settings.export_hair = params->export_hair;
- job->settings.export_particles = params->export_particles;
- job->settings.apply_subdiv = params->apply_subdiv;
- job->settings.curves_as_mesh = params->curves_as_mesh;
- job->settings.flatten_hierarchy = params->flatten_hierarchy;
-
- /* TODO(Sybren): visible_layer & renderable only is ignored for now,
- * to be replaced with collections later in the 2.8 dev process
- * (also see note above). */
- job->settings.visible_objects_only = params->visible_objects_only;
- job->settings.renderable_only = params->renderable_only;
-
- job->settings.use_subdiv_schema = params->use_subdiv_schema;
- job->settings.pack_uv = params->packuv;
- job->settings.global_scale = params->global_scale;
- job->settings.triangulate = params->triangulate;
- job->settings.quad_method = params->quad_method;
- job->settings.ngon_method = params->ngon_method;
-
- if (job->settings.frame_start > job->settings.frame_end) {
- std::swap(job->settings.frame_start, job->settings.frame_end);
- }
-
- bool export_ok = false;
- if (as_background_job) {
- wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
- CTX_wm_window(C),
- job->settings.scene,
- "Alembic Export",
- WM_JOB_PROGRESS,
- WM_JOB_TYPE_ALEMBIC);
-
- /* setup job */
- WM_jobs_customdata_set(wm_job, job, MEM_freeN);
- WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_FRAME, NC_SCENE | ND_FRAME);
- WM_jobs_callbacks(wm_job, export_startjob, NULL, NULL, export_endjob);
-
- WM_jobs_start(CTX_wm_manager(C), wm_job);
- }
- else {
- /* Fake a job context, so that we don't need NULL pointer checks while exporting. */
- short stop = 0, do_update = 0;
- float progress = 0.f;
-
- export_startjob(job, &stop, &do_update, &progress);
- export_endjob(job);
- export_ok = job->export_ok;
-
- MEM_freeN(job);
- }
-
- return export_ok;
-}
-
/* ********************** Import file ********************** */
/**