[Bf-blender-cvs] [f2ffc2c0b86] sybren-usd: USD: added debug function for printing the export graph

Sybren A. Stüvel noreply at git.blender.org
Fri Jul 19 11:15:25 CEST 2019


Commit: f2ffc2c0b8622fd9ae785e68c2f4e09a01eb98bf
Author: Sybren A. Stüvel
Date:   Wed Jul 17 14:35:34 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rBf2ffc2c0b8622fd9ae785e68c2f4e09a01eb98bf

USD: added debug function for printing the export graph

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

M	source/blender/usd/intern/abstract_hierarchy_iterator.cc
M	source/blender/usd/intern/abstract_hierarchy_iterator.h

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

diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index 10379b0a2b9..b8a6dcad548 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -60,6 +60,41 @@ void AbstractHierarchyIterator::release_writers()
   writers.clear();
 }
 
+void AbstractHierarchyIterator::debug_print_export_graph() const
+{
+  size_t total_graph_size = 0;
+  for (const ExportGraph::value_type &map_iter : export_graph) {
+    const std::pair<Object *, Object *> &parent_info = map_iter.first;
+    Object *const export_parent = parent_info.first;
+    Object *const duplicator = parent_info.second;
+
+    if (duplicator != nullptr) {
+      printf("    DU %s (as dupped by %s):\n",
+             export_parent == nullptr ? "-null-" : (export_parent->id.name + 2),
+             duplicator->id.name + 2);
+    }
+    else {
+      printf("    OB %s:\n", export_parent == nullptr ? "-null-" : (export_parent->id.name + 2));
+    }
+
+    total_graph_size += map_iter.second.size();
+    for (HierarchyContext *child_ctx : map_iter.second) {
+      if (child_ctx->duplicator == nullptr) {
+        printf("       - %s%s\n",
+               child_ctx->object->id.name + 2,
+               child_ctx->weak_export ? " \033[97m(weak)\033[0m" : "");
+      }
+      else {
+        printf("       - %s (dup by %s%s)\n",
+               child_ctx->object->id.name + 2,
+               child_ctx->duplicator->id.name + 2,
+               child_ctx->weak_export ? ", \033[97mweak\033[0m" : "");
+      }
+    }
+  }
+  printf("    (Total graph size: %lu objects\n", total_graph_size);
+}
+
 void AbstractHierarchyIterator::iterate()
 {
   export_graph_construct();
diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.h b/source/blender/usd/intern/abstract_hierarchy_iterator.h
index f2a1907bd8d..baa14969390 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.h
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.h
@@ -108,6 +108,8 @@ class AbstractHierarchyIterator {
   virtual std::string make_valid_name(const std::string &name) const;
 
  private:
+  void debug_print_export_graph() const;
+
   void export_graph_construct();
   void export_graph_prune();
   void export_graph_clear();



More information about the Bf-blender-cvs mailing list