Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2020-03-13 16:49:13 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-03-13 20:17:51 +0300
commitdc99c3532a736b6620e973dcd5447abc98bee77a (patch)
tree92b41cdf8f398e27a32d2302daa7d24b8849e998 /source/blender/io
parentebf3c87912364296d6548a6e7b09da0deda81b66 (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')
-rw-r--r--source/blender/io/usd/intern/abstract_hierarchy_iterator.cc28
-rw-r--r--source/blender/io/usd/intern/abstract_hierarchy_iterator.h2
-rw-r--r--source/blender/io/usd/intern/usd_writer_abstract.cc32
-rw-r--r--source/blender/io/usd/intern/usd_writer_abstract.h1
4 files changed, 30 insertions, 33 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_()
{
diff --git a/source/blender/io/usd/intern/abstract_hierarchy_iterator.h b/source/blender/io/usd/intern/abstract_hierarchy_iterator.h
index c121e3b704d..64c831877ab 100644
--- a/source/blender/io/usd/intern/abstract_hierarchy_iterator.h
+++ b/source/blender/io/usd/intern/abstract_hierarchy_iterator.h
@@ -115,6 +115,8 @@ class AbstractHierarchyWriter {
// TODO(Sybren): add function like absent() that's called when a writer was previously created,
// but wasn't used while exporting the current frame (for example, a particle-instanced mesh of
// which the particle is no longer alive).
+ protected:
+ virtual bool check_is_animated(const HierarchyContext &context) const;
};
/* AbstractHierarchyIterator iterates over objects in a dependency graph, and constructs export
diff --git a/source/blender/io/usd/intern/usd_writer_abstract.cc b/source/blender/io/usd/intern/usd_writer_abstract.cc
index 4d0b4364fb5..76a2436ee92 100644
--- a/source/blender/io/usd/intern/usd_writer_abstract.cc
+++ b/source/blender/io/usd/intern/usd_writer_abstract.cc
@@ -21,13 +21,6 @@
#include <pxr/base/tf/stringUtils.h>
-extern "C" {
-#include "BKE_animsys.h"
-#include "BKE_key.h"
-
-#include "DNA_modifier_types.h"
-}
-
/* TfToken objects are not cheap to construct, so we do it once. */
namespace usdtokens {
// Materials
@@ -85,31 +78,6 @@ void USDAbstractWriter::write(HierarchyContext &context)
frame_has_been_written_ = true;
}
-bool USDAbstractWriter::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;
-}
-
const pxr::SdfPath &USDAbstractWriter::usd_path() const
{
return usd_export_context_.usd_path;
diff --git a/source/blender/io/usd/intern/usd_writer_abstract.h b/source/blender/io/usd/intern/usd_writer_abstract.h
index 835d3a42c80..ad8049f499c 100644
--- a/source/blender/io/usd/intern/usd_writer_abstract.h
+++ b/source/blender/io/usd/intern/usd_writer_abstract.h
@@ -66,7 +66,6 @@ class USDAbstractWriter : public AbstractHierarchyWriter {
protected:
virtual void do_write(HierarchyContext &context) = 0;
- virtual bool check_is_animated(const HierarchyContext &context) const;
pxr::UsdTimeCode get_export_time_code() const;
pxr::UsdShadeMaterial ensure_usd_material(Material *material);