[Bf-blender-cvs] [078e2dd0034] temp-alembic-exporter-T73363-ms2: Alembic: added ability to export as flattened hierarchy

Sybren A. Stüvel noreply at git.blender.org
Thu May 7 16:56:02 CEST 2020


Commit: 078e2dd0034e92169579436b441ea23fd12daa9e
Author: Sybren A. Stüvel
Date:   Thu May 7 16:53:55 2020 +0200
Branches: temp-alembic-exporter-T73363-ms2
https://developer.blender.org/rB078e2dd0034e92169579436b441ea23fd12daa9e

Alembic: added ability to export as flattened hierarchy

I'm not entirely happy that this invades into the `AbstractHierarchyIterator`
class, so I might revisit this later.

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

M	source/blender/io/alembic/intern/export/abc_hierarchy_iterator.cc
M	source/blender/io/usd/intern/abstract_hierarchy_iterator.cc
M	source/blender/io/usd/intern/abstract_hierarchy_iterator.h

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

diff --git a/source/blender/io/alembic/intern/export/abc_hierarchy_iterator.cc b/source/blender/io/alembic/intern/export/abc_hierarchy_iterator.cc
index e78afdb31f1..551b62ec81a 100644
--- a/source/blender/io/alembic/intern/export/abc_hierarchy_iterator.cc
+++ b/source/blender/io/alembic/intern/export/abc_hierarchy_iterator.cc
@@ -48,6 +48,7 @@ ABCHierarchyIterator::ABCHierarchyIterator(Depsgraph *depsgraph,
                                            const AlembicExportParams &params)
     : AbstractHierarchyIterator(depsgraph), abc_archive_(abc_archive), params_(params)
 {
+  export_flattened_ = params_.flatten_hierarchy;
 }
 
 bool ABCHierarchyIterator::mark_as_weak_export(const Object *object) const
diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc
index f603bd81c7a..5d6695b5a5c 100644
--- a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc
@@ -106,7 +106,7 @@ bool AbstractHierarchyWriter::check_is_animated(const HierarchyContext &context)
 }
 
 AbstractHierarchyIterator::AbstractHierarchyIterator(Depsgraph *depsgraph)
-    : depsgraph_(depsgraph), writers_(), export_subset_({true, true})
+    : depsgraph_(depsgraph), writers_(), export_subset_({true, true}), export_flattened_(false)
 {
 }
 
@@ -339,6 +339,10 @@ void AbstractHierarchyIterator::visit_object(Object *object,
                                              Object *export_parent,
                                              bool weak_export)
 {
+  if (export_flattened_) {
+    export_parent = nullptr;
+  }
+
   HierarchyContext *context = new HierarchyContext();
   context->object = object;
   context->export_name = get_object_name(object);
@@ -381,21 +385,28 @@ void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object,
   context->original_export_path = "";
   context->export_path = "";
 
-  /* If the dupli-object's parent is also instanced by this object, use that as the
-   * export parent. Otherwise use the dupli-parent as export parent. */
-  Object *parent = dupli_object->ob->parent;
-  if (parent != nullptr && dupli_set.find(parent) != dupli_set.end()) {
-    // The parent object is part of the duplicated collection.
-    context->export_parent = parent;
-    graph_index = std::make_pair(parent, duplicator);
+  if (export_flattened_) {
+    context->export_parent = nullptr;
+    graph_index = std::make_pair(nullptr, nullptr);
+    animation_check_include_parent = true;
   }
   else {
-    /* The parent object is NOT part of the duplicated collection. This means that the world
-     * transform of this dupli-object can be influenced by objects that are not part of its
-     * export graph. */
-    animation_check_include_parent = true;
-    context->export_parent = duplicator;
-    graph_index = std::make_pair(duplicator, nullptr);
+    /* If the dupli-object's parent is also instanced by this object, use that as the
+     * export parent. Otherwise use the dupli-parent as export parent. */
+    Object *parent = dupli_object->ob->parent;
+    if (parent != nullptr && dupli_set.find(parent) != dupli_set.end()) {
+      // The parent object is part of the duplicated collection.
+      context->export_parent = parent;
+      graph_index = std::make_pair(parent, duplicator);
+    }
+    else {
+      /* The parent object is NOT part of the duplicated collection. This means that the world
+       * transform of this dupli-object can be influenced by objects that are not part of its
+       * export graph. */
+      animation_check_include_parent = true;
+      context->export_parent = duplicator;
+      graph_index = std::make_pair(duplicator, nullptr);
+    }
   }
 
   context->animation_check_include_parent = animation_check_include_parent;
diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.h b/source/blender/io/usd/intern/abstract_hierarchy_iterator.h
index fcd3cfca781..eec3d394b1e 100644
--- a/source/blender/io/usd/intern/abstract_hierarchy_iterator.h
+++ b/source/blender/io/usd/intern/abstract_hierarchy_iterator.h
@@ -163,6 +163,9 @@ class AbstractHierarchyIterator {
   WriterMap writers_;
   ExportSubset export_subset_;
 
+  /* When this is true, all objects are exported as child of the archive root. */
+  bool export_flattened_;
+
  public:
   explicit AbstractHierarchyIterator(Depsgraph *depsgraph);
   virtual ~AbstractHierarchyIterator();



More information about the Bf-blender-cvs mailing list