Cleanup: Alembic export, split `ABCHierarchyIterator::get_alembic_parent()`

Split `ABCHierarchyIterator::get_alembic_parent()` into two functions:
- For a given export path, find the Alembic object
- Ensure that that object is usable as parent object (Alembic uses a
  specific 'top' object as parent to indicate "no parent").

The new function is `public` as it will be used in an upcoming feature,
and is required to be public then.

No functional changes.
This commit is contained in:
Sybren A. Stüvel 2020-09-08 14:16:54 +02:00
parent c0b4a93fae
commit 9421d66a1b
2 changed files with 19 additions and 7 deletions

View File

@ -126,16 +126,26 @@ AbstractHierarchyIterator::ExportGraph::key_type ABCHierarchyIterator::determine
context, dupli_object, dupli_parent_finder);
}
Alembic::Abc::OObject ABCHierarchyIterator::get_alembic_object(
const std::string &export_path) const
{
if (export_path.empty()) {
return Alembic::Abc::OObject();
}
AbstractHierarchyWriter *writer = get_writer(export_path);
if (writer == nullptr) {
return Alembic::Abc::OObject();
}
ABCAbstractWriter *abc_writer = static_cast<ABCAbstractWriter *>(writer);
return abc_writer->get_alembic_object();
}
Alembic::Abc::OObject ABCHierarchyIterator::get_alembic_parent(
const HierarchyContext *context) const
{
Alembic::Abc::OObject parent;
if (!context->higher_up_export_path.empty()) {
AbstractHierarchyWriter *writer = get_writer(context->higher_up_export_path);
ABCAbstractWriter *abc_writer = static_cast<ABCAbstractWriter *>(writer);
parent = abc_writer->get_alembic_object();
}
Alembic::Abc::OObject parent = get_alembic_object(context->higher_up_export_path);
if (!parent.valid()) {
/* An invalid parent object means "no parent", which should be translated to Alembic's top

View File

@ -62,6 +62,8 @@ class ABCHierarchyIterator : public AbstractHierarchyIterator {
virtual void iterate_and_write() override;
virtual std::string make_valid_name(const std::string &name) const override;
Alembic::Abc::OObject get_alembic_object(const std::string &export_path) const;
protected:
virtual bool mark_as_weak_export(const Object *object) const override;