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-09-08 15:14:04 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-09-08 17:19:54 +0300
commitc0b4a93faedbbf53761fa86aafcc458f140700a2 (patch)
tree23bc7f92f9de60fc98ecd97d8cf3bd6d86440151
parentab758c30d2ba46eabd9774951afaed52c8344855 (diff)
Cleanup: Alembic export, split function into two
Split the `ABCHierarchyIterator::create_data_writer()` function into two functions. This is to prepare for the creation of writers not just by object type, but also by goal, for example writers that reference other Alembic data instead of writing their own (i.e. instancing). No functional changes.
-rw-r--r--source/blender/io/alembic/exporter/abc_hierarchy_iterator.cc46
-rw-r--r--source/blender/io/alembic/exporter/abc_hierarchy_iterator.h4
2 files changed, 26 insertions, 24 deletions
diff --git a/source/blender/io/alembic/exporter/abc_hierarchy_iterator.cc b/source/blender/io/alembic/exporter/abc_hierarchy_iterator.cc
index 5b1b1b60b48..e8ca06d75fc 100644
--- a/source/blender/io/alembic/exporter/abc_hierarchy_iterator.cc
+++ b/source/blender/io/alembic/exporter/abc_hierarchy_iterator.cc
@@ -171,34 +171,37 @@ AbstractHierarchyWriter *ABCHierarchyIterator::create_transform_writer(
AbstractHierarchyWriter *ABCHierarchyIterator::create_data_writer(const HierarchyContext *context)
{
const ABCWriterConstructorArgs writer_args = writer_constructor_args(context);
- ABCAbstractWriter *data_writer = nullptr;
+ ABCAbstractWriter *data_writer = create_data_writer_for_object_type(context, writer_args);
+ if (data_writer == nullptr || !data_writer->is_supported(context)) {
+ delete data_writer;
+ return nullptr;
+ }
+
+ data_writer->create_alembic_objects(context);
+ return data_writer;
+}
+
+ABCAbstractWriter *ABCHierarchyIterator::create_data_writer_for_object_type(
+ const HierarchyContext *context, const ABCWriterConstructorArgs &writer_args)
+{
switch (context->object->type) {
case OB_MESH:
- data_writer = new ABCMeshWriter(writer_args);
- break;
+ return new ABCMeshWriter(writer_args);
case OB_CAMERA:
- data_writer = new ABCCameraWriter(writer_args);
- break;
+ return new ABCCameraWriter(writer_args);
case OB_CURVE:
if (params_.curves_as_mesh) {
- data_writer = new ABCCurveMeshWriter(writer_args);
+ return new ABCCurveMeshWriter(writer_args);
}
- else {
- data_writer = new ABCCurveWriter(writer_args);
- }
- break;
+ return new ABCCurveWriter(writer_args);
case OB_SURF:
if (params_.curves_as_mesh) {
- data_writer = new ABCCurveMeshWriter(writer_args);
- }
- else {
- data_writer = new ABCNurbsWriter(writer_args);
+ return new ABCCurveMeshWriter(writer_args);
}
- break;
+ return new ABCNurbsWriter(writer_args);
case OB_MBALL:
- data_writer = new ABCMetaballWriter(writer_args);
- break;
+ return new ABCMetaballWriter(writer_args);
case OB_EMPTY:
case OB_LAMP:
@@ -214,13 +217,8 @@ AbstractHierarchyWriter *ABCHierarchyIterator::create_data_writer(const Hierarch
return nullptr;
}
- if (!data_writer->is_supported(context)) {
- delete data_writer;
- return nullptr;
- }
-
- data_writer->create_alembic_objects(context);
- return data_writer;
+ /* Just to please the compiler, all cases should be handled by the above switch. */
+ return nullptr;
}
AbstractHierarchyWriter *ABCHierarchyIterator::create_hair_writer(const HierarchyContext *context)
diff --git a/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h b/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h
index bd7e3f27c67..b8abfd74c4c 100644
--- a/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h
+++ b/source/blender/io/alembic/exporter/abc_hierarchy_iterator.h
@@ -36,6 +36,7 @@ namespace blender {
namespace io {
namespace alembic {
+class ABCAbstractWriter;
class ABCHierarchyIterator;
struct ABCWriterConstructorArgs {
@@ -85,6 +86,9 @@ class ABCHierarchyIterator : public AbstractHierarchyIterator {
ABCWriterConstructorArgs writer_constructor_args(const HierarchyContext *context) const;
void update_archive_bounding_box();
void update_bounding_box_recursive(Imath::Box3d &bounds, const HierarchyContext *context);
+
+ ABCAbstractWriter *create_data_writer_for_object_type(
+ const HierarchyContext *context, const ABCWriterConstructorArgs &writer_args);
};
} // namespace alembic