diff options
Diffstat (limited to 'source/blender/io/common/IO_abstract_hierarchy_iterator.h')
-rw-r--r-- | source/blender/io/common/IO_abstract_hierarchy_iterator.h | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/source/blender/io/common/IO_abstract_hierarchy_iterator.h b/source/blender/io/common/IO_abstract_hierarchy_iterator.h index 5f84fd48b71..2669f137fd4 100644 --- a/source/blender/io/common/IO_abstract_hierarchy_iterator.h +++ b/source/blender/io/common/IO_abstract_hierarchy_iterator.h @@ -36,6 +36,8 @@ #ifndef __ABSTRACT_HIERARCHY_ITERATOR_H__ #define __ABSTRACT_HIERARCHY_ITERATOR_H__ +#include "IO_dupli_persistent_id.hh" + #include <map> #include <set> #include <string> @@ -52,6 +54,7 @@ namespace blender { namespace io { class AbstractHierarchyWriter; +class DupliParentFinder; /* HierarchyContext structs are created by the AbstractHierarchyIterator. Each HierarchyContext * struct contains everything necessary to export a single object to a file. */ @@ -60,6 +63,7 @@ struct HierarchyContext { Object *object; /* Evaluated object. */ Object *export_parent; Object *duplicator; + PersistentID persistent_id; float matrix_world[4][4]; std::string export_name; @@ -161,6 +165,35 @@ class EnsuredWriter { AbstractHierarchyWriter *operator->(); }; +/* Unique identifier for a (potentially duplicated) object. + * + * Instances of this class serve as key in the export graph of the + * AbstractHierarchyIterator. */ +class ObjectIdentifier { + public: + Object *object; + Object *duplicated_by; /* nullptr for real objects. */ + PersistentID persistent_id; + + protected: + ObjectIdentifier(Object *object, Object *duplicated_by, const PersistentID &persistent_id); + + public: + ObjectIdentifier(const ObjectIdentifier &other); + ~ObjectIdentifier(); + + static ObjectIdentifier for_graph_root(); + static ObjectIdentifier for_real_object(Object *object); + static ObjectIdentifier for_hierarchy_context(const HierarchyContext *context); + static ObjectIdentifier for_duplicated_object(const DupliObject *dupli_object, + Object *duplicated_by); + + bool is_root() const; +}; + +bool operator<(const ObjectIdentifier &obj_ident_a, const ObjectIdentifier &obj_ident_b); +bool operator==(const ObjectIdentifier &obj_ident_a, const ObjectIdentifier &obj_ident_b); + /* AbstractHierarchyIterator iterates over objects in a dependency graph, and constructs export * writers. These writers are then called to perform the actual writing to a USD or Alembic file. * @@ -172,14 +205,10 @@ class AbstractHierarchyIterator { public: /* Mapping from export path to writer. */ typedef std::map<std::string, AbstractHierarchyWriter *> WriterMap; - /* Pair of a (potentially duplicated) object and its duplicator (or nullptr). - * This is typically used to store a pair of HierarchyContext::object and - * HierarchyContext::duplicator. */ - typedef std::pair<Object *, Object *> DupliAndDuplicator; /* All the children of some object, as per the export hierarchy. */ typedef std::set<HierarchyContext *> ExportChildren; /* Mapping from an object and its duplicator to the object's export-children. */ - typedef std::map<DupliAndDuplicator, ExportChildren> ExportGraph; + typedef std::map<ObjectIdentifier, ExportChildren> ExportGraph; /* Mapping from ID to its export path. This is used for instancing; given an * instanced datablock, the export path of the original can be looked up. */ typedef std::map<ID *, std::string> ExportPathMap; @@ -237,7 +266,7 @@ class AbstractHierarchyIterator { void visit_object(Object *object, Object *export_parent, bool weak_export); void visit_dupli_object(DupliObject *dupli_object, Object *duplicator, - const std::set<Object *> &dupli_set); + const DupliParentFinder &dupli_parent_finder); void context_update_for_graph_index(HierarchyContext *context, const ExportGraph::key_type &graph_index) const; @@ -291,8 +320,10 @@ class AbstractHierarchyIterator { virtual bool should_visit_dupli_object(const DupliObject *dupli_object) const; virtual ExportGraph::key_type determine_graph_index_object(const HierarchyContext *context); - virtual ExportGraph::key_type determine_graph_index_dupli(const HierarchyContext *context, - const std::set<Object *> &dupli_set); + virtual ExportGraph::key_type determine_graph_index_dupli( + const HierarchyContext *context, + const DupliObject *dupli_object, + const DupliParentFinder &dupli_parent_finder); /* These functions should create an AbstractHierarchyWriter subclass instance, or return * nullptr if the object or its data should not be exported. Returning a nullptr for |