diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-03-13 16:49:13 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-03-13 20:17:51 +0300 |
commit | dc99c3532a736b6620e973dcd5447abc98bee77a (patch) | |
tree | 92b41cdf8f398e27a32d2302daa7d24b8849e998 /source/blender/io/usd/intern/abstract_hierarchy_iterator.cc | |
parent | ebf3c87912364296d6548a6e7b09da0deda81b66 (diff) |
Cleanup: USD, move some common code to an abstract superclass
The `check_is_animated()` function will be used by the upcoming Alembic
exporter as well. There is nothing USD-specific in the function.
No functional changes.
Diffstat (limited to 'source/blender/io/usd/intern/abstract_hierarchy_iterator.cc')
-rw-r--r-- | source/blender/io/usd/intern/abstract_hierarchy_iterator.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc index a958a445a3d..50f81c2ffb1 100644 --- a/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/usd/intern/abstract_hierarchy_iterator.cc @@ -25,6 +25,8 @@ extern "C" { #include "BKE_anim.h" +#include "BKE_animsys.h" +#include "BKE_key.h" #include "BKE_particle.h" #include "BLI_assert.h" @@ -33,6 +35,7 @@ extern "C" { #include "DNA_ID.h" #include "DNA_layer_types.h" +#include "DNA_modifier_types.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" @@ -76,6 +79,31 @@ AbstractHierarchyWriter::~AbstractHierarchyWriter() { } +bool AbstractHierarchyWriter::check_is_animated(const HierarchyContext &context) const +{ + const Object *object = context.object; + + if (BKE_animdata_id_is_animated(static_cast<ID *>(object->data))) { + return true; + } + if (BKE_key_from_object(object) != nullptr) { + return true; + } + + /* Test modifiers. */ + /* TODO(Sybren): replace this with a check on the depsgraph to properly check for dependency on + * time. */ + ModifierData *md = static_cast<ModifierData *>(object->modifiers.first); + while (md) { + if (md->type != eModifierType_Subsurf) { + return true; + } + md = md->next; + } + + return false; +} + AbstractHierarchyIterator::AbstractHierarchyIterator(Depsgraph *depsgraph) : depsgraph_(depsgraph), writers_() { |