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 17:15:49 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-09-08 17:41:59 +0300
commitb3759cc0d67eeb8cec55314d3304db0bc02168af (patch)
tree83903d61963f58e93702bced40d23b27050381ad /source/blender/io/alembic/exporter/abc_writer_instance.cc
parent8f4f9275cea6602e74eecf7e9a88c101f9cc5245 (diff)
Alembic Export: support instanced object data
Add support for object data instancing. This is used when the objects are instances, for example when duplicated by a particle system, or instanced by the duplication system (collection-duplicating empties, vertex/face duplis, etc.) Since Alembic already deduplicates data, this doesn't make the resulting Alembic files any smaller. They will be faster to write, though, when there is a lot of instanced geometry, as the deduplication system won't have to do any comparisons. This instancing support is still limited, in the sense that only object data is instanced and all transforms are still written explicitly. A future improvement could be to support instancing entire collection hierarchies. Blender's Alembic importer has no understanding of these Alembic instances yet, and will thus happily duplicate the data on import. The USD Alembic plugin seems to have problems understanding the instancing. There might also be other software with similar issues. Because of this, instancing can be turned off in the exporter (it's on by default).
Diffstat (limited to 'source/blender/io/alembic/exporter/abc_writer_instance.cc')
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_instance.cc74
1 files changed, 74 insertions, 0 deletions
diff --git a/source/blender/io/alembic/exporter/abc_writer_instance.cc b/source/blender/io/alembic/exporter/abc_writer_instance.cc
new file mode 100644
index 00000000000..581d94ee961
--- /dev/null
+++ b/source/blender/io/alembic/exporter/abc_writer_instance.cc
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/** \file
+ * \ingroup balembic
+ */
+
+#include "abc_writer_instance.h"
+#include "abc_hierarchy_iterator.h"
+
+#include "BLI_assert.h"
+
+#include "CLG_log.h"
+static CLG_LogRef LOG = {"io.alembic"};
+
+namespace blender {
+namespace io {
+namespace alembic {
+
+using Alembic::Abc::OObject;
+
+ABCInstanceWriter::ABCInstanceWriter(const ABCWriterConstructorArgs &args)
+ : ABCAbstractWriter(args)
+{
+}
+
+ABCInstanceWriter::~ABCInstanceWriter()
+{
+}
+
+void ABCInstanceWriter::create_alembic_objects(const HierarchyContext *context)
+{
+ OObject original = args_.hierarchy_iterator->get_alembic_object(context->original_export_path);
+ OObject abc_parent = args_.abc_parent;
+ if (!abc_parent.addChildInstance(original, args_.abc_name)) {
+ CLOG_WARN(&LOG, "unable to export %s as instance", args_.abc_path.c_str());
+ return;
+ }
+ CLOG_INFO(&LOG, 2, "exporting instance %s", args_.abc_path.c_str());
+}
+
+OObject ABCInstanceWriter::get_alembic_object() const
+{
+ /* There is no OObject for an instance. */
+ BLI_assert(!"ABCInstanceWriter cannot return its Alembic OObject");
+ return OObject();
+}
+
+bool ABCInstanceWriter::is_supported(const HierarchyContext *context) const
+{
+ return context->is_instance();
+}
+
+void ABCInstanceWriter::do_write(HierarchyContext & /*context*/)
+{
+ /* Instances don't have data to be written. Just creating them is enough. */
+}
+
+} // namespace alembic
+} // namespace io
+} // namespace blender