diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-10-10 10:19:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-10-10 14:04:51 +0300 |
commit | 2abfcebb0eb7989e3d1e7d03f37ecf5c088210af (patch) | |
tree | e7a1ad5912b4661d4ece743f4f7fd86e6bf4d3c4 /source/blender/io/common/intern/abstract_hierarchy_iterator.cc | |
parent | c735aca42e9f5961fec7e5d5fc196b5bd6b85f56 (diff) |
Cleanup: use C comments for descriptive text
Follow our code style guide by using C-comments for text descriptions.
Diffstat (limited to 'source/blender/io/common/intern/abstract_hierarchy_iterator.cc')
-rw-r--r-- | source/blender/io/common/intern/abstract_hierarchy_iterator.cc | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc index 6e763c29631..6077fc89b91 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc @@ -57,7 +57,7 @@ bool HierarchyContext::operator<(const HierarchyContext &other) const return object < other.object; } if (duplicator != nullptr && duplicator == other.duplicator) { - // Only resort to string comparisons when both objects are created by the same duplicator. + /* Only resort to string comparisons when both objects are created by the same duplicator. */ return export_name < other.export_name; } @@ -291,16 +291,16 @@ void AbstractHierarchyIterator::export_graph_construct() object, DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET) { - // Non-instanced objects always have their object-parent as export-parent. + /* Non-instanced objects always have their object-parent as export-parent. */ const bool weak_export = mark_as_weak_export(object); visit_object(object, object->parent, weak_export); if (weak_export) { - // If a duplicator shouldn't be exported, its duplilist also shouldn't be. + /* If a duplicator shouldn't be exported, its duplilist also shouldn't be. */ continue; } - // Export the duplicated objects instanced by this object. + /* Export the duplicated objects instanced by this object. */ ListBase *lb = object_duplilist(depsgraph_, scene, object); if (lb) { DupliParentFinder dupli_parent_finder; @@ -328,29 +328,29 @@ void AbstractHierarchyIterator::export_graph_construct() void AbstractHierarchyIterator::connect_loose_objects() { - // Find those objects whose parent is not part of the export graph; these - // objects would be skipped when traversing the graph as a hierarchy. - // These objects will have to be re-attached to some parent object in order to - // fit into the hierarchy. + /* Find those objects whose parent is not part of the export graph; these + * objects would be skipped when traversing the graph as a hierarchy. + * These objects will have to be re-attached to some parent object in order to + * fit into the hierarchy. */ ExportGraph loose_objects_graph = export_graph_; for (const ExportGraph::value_type &map_iter : export_graph_) { for (const HierarchyContext *child : map_iter.second) { - // An object that is marked as a child of another object is not considered 'loose'. + /* An object that is marked as a child of another object is not considered 'loose'. */ ObjectIdentifier child_oid = ObjectIdentifier::for_hierarchy_context(child); loose_objects_graph.erase(child_oid); } } - // The root of the hierarchy is always found, so it's never considered 'loose'. + /* The root of the hierarchy is always found, so it's never considered 'loose'. */ loose_objects_graph.erase(ObjectIdentifier::for_graph_root()); - // Iterate over the loose objects and connect them to their export parent. + /* Iterate over the loose objects and connect them to their export parent. */ for (const ExportGraph::value_type &map_iter : loose_objects_graph) { const ObjectIdentifier &graph_key = map_iter.first; Object *object = graph_key.object; while (true) { - // Loose objects will all be real objects, as duplicated objects always have - // their duplicator or other exported duplicated object as ancestor. + /* Loose objects will all be real objects, as duplicated objects always have + * their duplicator or other exported duplicated object as ancestor. */ ExportGraph::iterator found_parent_iter = export_graph_.find( ObjectIdentifier::for_real_object(object->parent)); @@ -358,8 +358,8 @@ void AbstractHierarchyIterator::connect_loose_objects() if (found_parent_iter != export_graph_.end()) { break; } - // 'object->parent' will never be nullptr here, as the export graph contains the - // root as nullptr and thus will cause a break above. + /* 'object->parent' will never be nullptr here, as the export graph contains the + * root as nullptr and thus will cause a break above. */ BLI_assert(object->parent != nullptr); object = object->parent; @@ -383,7 +383,7 @@ static bool remove_weak_subtrees(const HierarchyContext *context, all_is_weak &= child_tree_is_weak; if (child_tree_is_weak) { - // This subtree is all weak, so we can remove it from the current object's children. + /* This subtree is all weak, so we can remove it from the current object's children. */ clean_graph[map_key].erase(child_context); delete child_context; } @@ -391,7 +391,7 @@ static bool remove_weak_subtrees(const HierarchyContext *context, } if (all_is_weak) { - // This node and all its children are weak, so it can be removed from the export graph. + /* This node and all its children are weak, so it can be removed from the export graph. */ clean_graph.erase(map_key); } @@ -400,7 +400,7 @@ static bool remove_weak_subtrees(const HierarchyContext *context, void AbstractHierarchyIterator::export_graph_prune() { - // Take a copy of the map so that we can modify while recursing. + /* Take a copy of the map so that we can modify while recursing. */ ExportGraph unpruned_export_graph = export_graph_; remove_weak_subtrees(HierarchyContext::root(), export_graph_, unpruned_export_graph); } @@ -435,14 +435,14 @@ void AbstractHierarchyIterator::visit_object(Object *object, ExportGraph::key_type graph_index = determine_graph_index_object(context); context_update_for_graph_index(context, graph_index); - // Store this HierarchyContext as child of the export parent. + /* Store this HierarchyContext as child of the export parent. */ export_graph_[graph_index].insert(context); - // Create an empty entry for this object to indicate it is part of the export. This will be used - // by connect_loose_objects(). Having such an "indicator" will make it possible to do an O(log n) - // check on whether an object is part of the export, rather than having to check all objects in - // the map. Note that it's not possible to simply search for (object->parent, nullptr), as the - // object's parent in Blender may not be the same as its export-parent. + /* Create an empty entry for this object to indicate it is part of the export. This will be used + * by connect_loose_objects(). Having such an "indicator" will make it possible to do an O(log n) + * check on whether an object is part of the export, rather than having to check all objects in + * the map. Note that it's not possible to simply search for (object->parent, nullptr), as the + * object's parent in Blender may not be the same as its export-parent. */ ExportGraph::key_type object_key = ObjectIdentifier::for_real_object(object); if (export_graph_.find(object_key) == export_graph_.end()) { export_graph_[object_key] = ExportChildren(); @@ -471,7 +471,7 @@ void AbstractHierarchyIterator::visit_dupli_object(DupliObject *dupli_object, copy_m4_m4(context->matrix_world, dupli_object->mat); - // Construct export name for the dupli-instance. + /* Construct export name for the dupli-instance. */ std::stringstream export_name_stream; export_name_stream << get_object_name(context->object) << "-" << context->persistent_id.as_object_name_suffix(); @@ -500,7 +500,7 @@ AbstractHierarchyIterator::ExportGraph::key_type AbstractHierarchyIterator:: void AbstractHierarchyIterator::context_update_for_graph_index( HierarchyContext *context, const ExportGraph::key_type &graph_index) const { - // Update the HierarchyContext so that it is consistent with the graph index. + /* Update the HierarchyContext so that it is consistent with the graph index. */ context->export_parent = graph_index.object; if (context->export_parent != context->object->parent) { /* The parent object in Blender is NOT used as the export parent. This means @@ -550,7 +550,7 @@ void AbstractHierarchyIterator::determine_duplication_references( const ExportPathMap::const_iterator &it = duplisource_export_path_.find(source_id); if (it == duplisource_export_path_.end()) { - // The original was not found, so mark this instance as "the original". + /* The original was not found, so mark this instance as "the original". */ context->mark_as_not_instanced(); duplisource_export_path_[source_id] = context->export_path; } @@ -563,7 +563,7 @@ void AbstractHierarchyIterator::determine_duplication_references( const ExportPathMap::const_iterator &it = duplisource_export_path_.find(source_data_id); if (it == duplisource_export_path_.end()) { - // The original was not found, so mark this instance as "original". + /* The original was not found, so mark this instance as "original". */ std::string data_path = get_object_data_path(context); context->mark_as_not_instanced(); duplisource_export_path_[source_id] = context->export_path; @@ -588,19 +588,19 @@ void AbstractHierarchyIterator::make_writers(const HierarchyContext *parent_cont } for (HierarchyContext *context : graph_children(parent_context)) { - // Update the context so that it is correct for this parent-child relation. + /* Update the context so that it is correct for this parent-child relation. */ copy_m4_m4(context->parent_matrix_inv_world, parent_matrix_inv_world); if (parent_context != nullptr) { context->higher_up_export_path = parent_context->export_path; } - // Get or create the transform writer. + /* Get or create the transform writer. */ EnsuredWriter transform_writer = ensure_writer( context, &AbstractHierarchyIterator::create_transform_writer); if (!transform_writer) { - // Unable to export, so there is nothing to attach any children to; just abort this entire - // branch of the export hierarchy. + /* Unable to export, so there is nothing to attach any children to; just abort this entire + * branch of the export hierarchy. */ return; } @@ -617,11 +617,12 @@ void AbstractHierarchyIterator::make_writers(const HierarchyContext *parent_cont make_writer_object_data(context); } - // Recurse into this object's children. + /* Recurse into this object's children. */ make_writers(context); } - // TODO(Sybren): iterate over all unused writers and call unused_during_iteration() or something. + /* TODO(Sybren): iterate over all unused writers and call unused_during_iteration() or something. + */ } HierarchyContext AbstractHierarchyIterator::context_for_object_data( @@ -750,7 +751,7 @@ bool AbstractHierarchyIterator::mark_as_weak_export(const Object * /*object*/) c } bool AbstractHierarchyIterator::should_visit_dupli_object(const DupliObject *dupli_object) const { - // Removing dupli_object->no_draw hides things like custom bone shapes. + /* Removing dupli_object->no_draw hides things like custom bone shapes. */ return !dupli_object->no_draw; } |