diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-08-14 17:45:35 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-08-17 18:56:05 +0300 |
commit | fd3086833afea8b414506de6bb9ab6a5beaa7faa (patch) | |
tree | f250ce89efd30c4c383ccc6705cf226c9705ff01 /source/blender/io/common/intern/abstract_hierarchy_iterator.cc | |
parent | 04ae290024c58f5288644bf3464757de4b56b9e7 (diff) |
Cleanup: IO, reduce code duplication in USD and Alembic exporters
Move the object visibility check from Alembic/USD-specific code into the
`io/common` module.
No functional changes.
Diffstat (limited to 'source/blender/io/common/intern/abstract_hierarchy_iterator.cc')
-rw-r--r-- | source/blender/io/common/intern/abstract_hierarchy_iterator.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc index fbefc8c8e7e..93e7e677118 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc @@ -28,6 +28,7 @@ #include "BKE_anim_data.h" #include "BKE_duplilist.h" #include "BKE_key.h" +#include "BKE_object.h" #include "BKE_particle.h" #include "BLI_assert.h" @@ -77,6 +78,29 @@ void HierarchyContext::mark_as_not_instanced() original_export_path.clear(); } +bool HierarchyContext::is_object_visible(const enum eEvaluationMode evaluation_mode) const +{ + bool is_dupli = duplicator != nullptr; + int base_flag; + + if (is_dupli) { + /* Construct the object's base flags from its dupli-parent, just like is done in + * deg_objects_dupli_iterator_next(). Without this, the visibility check below will fail. Doing + * this here, instead of a more suitable location in AbstractHierarchyIterator, prevents + * copying the Object for every dupli. */ + base_flag = object->base_flag; + object->base_flag = duplicator->base_flag | BASE_FROM_DUPLI; + } + + int visibility = BKE_object_visibility(object, evaluation_mode); + + if (is_dupli) { + object->base_flag = base_flag; + } + + return (visibility & OB_VISIBLE_SELF) != 0; +} + EnsuredWriter::EnsuredWriter() : writer_(nullptr), newly_created_(false) { } |