Alembic export: fixed flattened dupligroup import
authorSybren A. Stüvel <sybren@stuvel.eu>
Fri, 14 Apr 2017 14:38:26 +0000 (16:38 +0200)
committerSybren A. Stüvel <sybren@stuvel.eu>
Fri, 14 Apr 2017 16:20:28 +0000 (18:20 +0200)
source/blender/alembic/intern/abc_exporter.cc
source/blender/alembic/intern/abc_exporter.h

index a8d1587abdb3286757767ab201023950f055f16a..d949df1b20aec08de0668095ff58cd39880d6e7d 100644 (file)
@@ -290,13 +290,7 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
 
        OBox3dProperty archive_bounds_prop = Alembic::AbcGeom::CreateOArchiveBounds(m_writer->archive(), m_trans_sampling_index);
 
-       if (m_settings.flatten_hierarchy) {
-               createTransformWritersFlat();
-       }
-       else {
-               createTransformWritersHierarchy(bmain->eval_ctx);
-       }
-
+       createTransformWritersHierarchy(bmain->eval_ctx);
        createShapeWriters(bmain->eval_ctx);
 
        /* Make a list of frames to export. */
@@ -383,24 +377,6 @@ void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx)
        }
 }
 
-void AbcExporter::createTransformWritersFlat()
-{
-       Base *base = static_cast<Base *>(m_scene->base.first);
-
-       while (base) {
-               Object *ob = base->object;
-
-               if (export_object(&m_settings, ob, false) && object_is_shape(ob)) {
-                       std::string name = get_id_name(ob);
-                       m_xforms[name] = new AbcTransformWriter(
-                                            ob, m_writer->archive().getTop(), NULL,
-                                            m_trans_sampling_index, m_settings);
-               }
-
-               base = base->next;
-       }
-}
-
 void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent)
 {
        /* If an object isn't exported itself, its duplilist shouldn't be
@@ -440,12 +416,18 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Obje
 
 AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupliObParent)
 {
-       const std::string name = get_object_dag_path_name(ob, dupliObParent);
-
        /* An object should not be its own parent, or we'll get infinite loops. */
        BLI_assert(ob != parent);
        BLI_assert(ob != dupliObParent);
 
+       std::string name;
+       if (m_settings.flatten_hierarchy) {
+               name = get_id_name(ob);
+       }
+       else {
+               name = get_object_dag_path_name(ob, dupliObParent);
+       }
+
        /* check if we have already created a transform writer for this object */
        AbcTransformWriter *my_writer = getXForm(name);
        if (my_writer != NULL){
@@ -455,7 +437,12 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare
        AbcTransformWriter *parent_writer = NULL;
        Alembic::Abc::OObject alembic_parent;
 
-       if (parent) {
+       if (m_settings.flatten_hierarchy || parent == NULL) {
+               /* Parentless objects still have the "top object" as parent
+                * in Alembic. */
+               alembic_parent = m_writer->archive().getTop();
+       }
+       else {
                /* Since there are so many different ways to find parents (as evident
                 * in the number of conditions below), we can't really look up the
                 * parent by name. We'll just call createTransformWriter(), which will
@@ -478,11 +465,6 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare
                BLI_assert(parent_writer);
                alembic_parent = parent_writer->alembicXform();
        }
-       else {
-               /* Parentless objects still have the "top object" as parent
-                * in Alembic. */
-               alembic_parent = m_writer->archive().getTop();
-       }
 
        my_writer = new AbcTransformWriter(ob, alembic_parent, parent_writer,
                                           m_trans_sampling_index, m_settings);
index 0f08037fd17852dbd2c77d24d25d20d74ce40ae6..73b7af280d9c09f50821638c67d14b26d6f22b80 100644 (file)
@@ -109,7 +109,6 @@ private:
        void getFrameSet(double step, std::set<double> &frames);
 
        void createTransformWritersHierarchy(EvaluationContext *eval_ctx);
-       void createTransformWritersFlat();
        AbcTransformWriter * createTransformWriter(Object *ob,  Object *parent, Object *dupliObParent);
        void exploreTransform(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent = NULL);
        void exploreObject(EvaluationContext *eval_ctx, Object *ob, Object *dupliObParent);