Merge branch 'master' into blender2.8
[blender.git] / source / blender / alembic / intern / abc_exporter.cc
index df2bc52aa2c42f4f5e13861308b95b170a126e7f..5635e3a94203df20c0e5acba2a4834d6b101adee 100644 (file)
@@ -28,6 +28,7 @@
 #include "abc_camera.h"
 #include "abc_curves.h"
 #include "abc_hair.h"
+#include "abc_mball.h"
 #include "abc_mesh.h"
 #include "abc_nurbs.h"
 #include "abc_points.h"
@@ -37,6 +38,7 @@
 extern "C" {
 #include "DNA_camera_types.h"
 #include "DNA_curve_types.h"
+#include "DNA_meta_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
@@ -54,6 +56,7 @@ extern "C" {
 #include "BKE_global.h"
 #include "BKE_idprop.h"
 #include "BKE_main.h"
+#include "BKE_mball.h"
 #include "BKE_modifier.h"
 #include "BKE_particle.h"
 #include "BKE_scene.h"
@@ -108,7 +111,7 @@ static bool object_is_smoke_sim(Object *ob)
        return false;
 }
 
-static bool object_type_is_exportable(Object *ob)
+static bool object_type_is_exportable(Scene *scene, Object *ob)
 {
        switch (ob->type) {
                case OB_MESH:
@@ -122,6 +125,8 @@ static bool object_type_is_exportable(Object *ob)
                case OB_SURF:
                case OB_CAMERA:
                        return true;
+               case OB_MBALL:
+                       return AbcMBallWriter::isBasisBall(scene, ob);
                default:
                        return false;
        }
@@ -163,8 +168,9 @@ static bool export_object(const ExportSettings * const settings, const Base * co
 
 /* ************************************************************************** */
 
-AbcExporter::AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings)
-    : m_settings(settings)
+AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings)
+    : m_bmain(bmain)
+    , m_settings(settings)
     , m_filename(filename)
     , m_trans_sampling_index(0)
     , m_shape_sampling_index(0)
@@ -361,11 +367,9 @@ void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx)
                        switch (ob->type) {
                                case OB_LAMP:
                                case OB_LATTICE:
-                               case OB_MBALL:
                                case OB_SPEAKER:
                                        /* We do not export transforms for objects of these classes. */
                                        break;
-
                                default:
                                        exploreTransform(eval_ctx, base, ob->parent, NULL);
                        }
@@ -383,7 +387,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, O
                return;
        }
 
-       if (object_type_is_exportable(ob)) {
+       if (object_type_is_exportable(m_scene, ob)) {
                createTransformWriter(eval_ctx, ob, parent, dupliObParent);
        }
 
@@ -553,7 +557,7 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
 {
        Object *ob = ob_base->object;
 
-       if (!object_type_is_exportable(ob)) {
+       if (!object_type_is_exportable(m_scene, ob)) {
                return;
        }
 
@@ -619,6 +623,18 @@ void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
 
                        break;
                }
+               case OB_MBALL:
+               {
+                       MetaBall *mball = static_cast<MetaBall *>(ob->data);
+                       if (!mball) {
+                               return;
+                       }
+
+                       m_shapes.push_back(new AbcMBallWriter(
+                                              m_bmain, m_eval_ctx, m_scene, ob, xform,
+                                              m_shape_sampling_index, m_settings));
+                       break;
+               }
        }
 }