diff options
Diffstat (limited to 'source/blender/alembic')
22 files changed, 175 insertions, 129 deletions
diff --git a/source/blender/alembic/CMakeLists.txt b/source/blender/alembic/CMakeLists.txt index a6e0be6a7f3..aa12b726d6b 100644 --- a/source/blender/alembic/CMakeLists.txt +++ b/source/blender/alembic/CMakeLists.txt @@ -29,6 +29,7 @@ set(INC ../blenlib ../blenloader ../bmesh + ../depsgraph ../editors/include ../makesdna ../makesrna diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc index 16416205983..aa5d77ce4ec 100644 --- a/source/blender/alembic/intern/abc_camera.cc +++ b/source/blender/alembic/intern/abc_camera.cc @@ -49,12 +49,13 @@ using Alembic::AbcGeom::kWrapExisting; /* ************************************************************************** */ -AbcCameraWriter::AbcCameraWriter(Scene *scene, +AbcCameraWriter::AbcCameraWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent) { OCamera camera(parent->alembicXform(), m_name, m_time_sampling); m_camera_schema = camera.getSchema(); diff --git a/source/blender/alembic/intern/abc_camera.h b/source/blender/alembic/intern/abc_camera.h index 16c5cccd5ea..772b7a6aec6 100644 --- a/source/blender/alembic/intern/abc_camera.h +++ b/source/blender/alembic/intern/abc_camera.h @@ -35,7 +35,8 @@ class AbcCameraWriter : public AbcObjectWriter { Alembic::AbcGeom::OFloatProperty m_eye_separation; public: - AbcCameraWriter(Scene *scene, + AbcCameraWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc index f73fe957fea..5328c471093 100644 --- a/source/blender/alembic/intern/abc_curves.cc +++ b/source/blender/alembic/intern/abc_curves.cc @@ -71,12 +71,13 @@ using Alembic::AbcGeom::OV2fGeomParam; /* ************************************************************************** */ -AbcCurveWriter::AbcCurveWriter(Scene *scene, +AbcCurveWriter::AbcCurveWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent) { OCurves curves(parent->alembicXform(), m_name, m_time_sampling); m_schema = curves.getSchema(); diff --git a/source/blender/alembic/intern/abc_curves.h b/source/blender/alembic/intern/abc_curves.h index a9231f947b2..73cc8b35e27 100644 --- a/source/blender/alembic/intern/abc_curves.h +++ b/source/blender/alembic/intern/abc_curves.h @@ -36,7 +36,8 @@ class AbcCurveWriter : public AbcObjectWriter { Alembic::AbcGeom::OCurvesSchema::Sample m_sample; public: - AbcCurveWriter(Scene *scene, + AbcCurveWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index 4fe65b96f36..df2bc52aa2c 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -131,43 +131,44 @@ static bool object_type_is_exportable(Object *ob) /** * Returns whether this object should be exported into the Alembic file. * - * \param settings: export settings, used for options like 'selected only'. - * \param ob: the object in question. + * \param settings export settings, used for options like 'selected only'. + * \param ob the object's base in question. * \param is_duplicated: Normally false; true when the object is instanced * into the scene by a dupli-object (e.g. part of a dupligroup). * This ignores selection and layer visibility, * and assumes that the dupli-object itself (e.g. the group-instantiating empty) is exported. */ -static bool export_object(const ExportSettings * const settings, Object *ob, +static bool export_object(const ExportSettings * const settings, const Base * const ob_base, bool is_duplicated) { if (!is_duplicated) { /* These two tests only make sense when the object isn't being instanced * into the scene. When it is, its exportability is determined by * its dupli-object and the DupliObject::no_draw property. */ - if (settings->selected_only && !parent_selected(ob)) { + if (settings->selected_only && !object_selected(ob_base)) { return false; } - - if (settings->visible_layers_only && !(settings->scene->lay & ob->lay)) { + // FIXME Sybren: handle these cleanly (maybe just remove code), now using active scene layer instead. + if (settings->visible_layers_only && (ob_base->flag & BASE_VISIBLED) == 0) { return false; } } - if (settings->renderable_only && (ob->restrictflag & OB_RESTRICT_RENDER)) { - return false; - } + // if (settings->renderable_only && (ob->restrictflag & OB_RESTRICT_RENDER)) { + // return false; + // } return true; } /* ************************************************************************** */ -AbcExporter::AbcExporter(Scene *scene, const char *filename, ExportSettings &settings) +AbcExporter::AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings) : m_settings(settings) , m_filename(filename) , m_trans_sampling_index(0) , m_shape_sampling_index(0) + , m_eval_ctx(eval_ctx) , m_scene(scene) , m_writer(NULL) {} @@ -353,42 +354,45 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled) void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx) { - Base *base = static_cast<Base *>(m_scene->base.first); - - while (base) { + for (Base *base = static_cast<Base *>(m_settings.sl->object_bases.first); base; base = base->next) { Object *ob = base->object; - 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, ob, ob->parent); + if (export_object(&m_settings, base, false)) { + 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); + } } - - base = base->next; } } -void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent) +void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent) { + Object *ob = ob_base->object; + /* If an object isn't exported itself, its duplilist shouldn't be * exported either. */ - if (!export_object(&m_settings, ob, dupliObParent != NULL)) { + if (!export_object(&m_settings, ob_base, dupliObParent != NULL)) { return; } if (object_type_is_exportable(ob)) { - createTransformWriter(ob, parent, dupliObParent); + createTransformWriter(eval_ctx, ob, parent, dupliObParent); } ListBase *lb = object_duplilist(eval_ctx, m_scene, ob); if (lb) { + Base fake_base = *ob_base; // copy flags (like selection state) from the real object. + fake_base.next = fake_base.prev = NULL; + DupliObject *link = static_cast<DupliObject *>(lb->first); Object *dupli_ob = NULL; Object *dupli_parent = NULL; @@ -403,7 +407,8 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Obje dupli_ob = link->ob; dupli_parent = (dupli_ob->parent) ? dupli_ob->parent : ob; - exploreTransform(eval_ctx, dupli_ob, dupli_parent, ob); + fake_base.object = dupli_ob; + exploreTransform(eval_ctx, &fake_base, dupli_parent, ob); } } } @@ -411,7 +416,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Obje free_object_duplilist(lb); } -AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupliObParent) +AbcTransformWriter * AbcExporter::createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent) { /* An object should not be its own parent, or we'll get infinite loops. */ BLI_assert(ob != parent); @@ -446,29 +451,29 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare * return the parent's AbcTransformWriter pointer. */ if (parent->parent) { if (parent == dupliObParent) { - parent_writer = createTransformWriter(parent, parent->parent, NULL); + parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, NULL); } else { - parent_writer = createTransformWriter(parent, parent->parent, dupliObParent); + parent_writer = createTransformWriter(eval_ctx, parent, parent->parent, dupliObParent); } } else if (parent == dupliObParent) { if (dupliObParent->parent == NULL) { - parent_writer = createTransformWriter(parent, NULL, NULL); + parent_writer = createTransformWriter(eval_ctx, parent, NULL, NULL); } else { - parent_writer = createTransformWriter(parent, dupliObParent->parent, dupliObParent->parent); + parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent->parent, dupliObParent->parent); } } else { - parent_writer = createTransformWriter(parent, dupliObParent, dupliObParent); + parent_writer = createTransformWriter(eval_ctx, parent, dupliObParent, dupliObParent); } BLI_assert(parent_writer); alembic_parent = parent_writer->alembicXform(); } - my_writer = new AbcTransformWriter(ob, alembic_parent, parent_writer, + my_writer = new AbcTransformWriter(eval_ctx, ob, alembic_parent, parent_writer, m_trans_sampling_index, m_settings); /* When flattening, the matrix of the dupliobject has to be added. */ @@ -482,29 +487,28 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare void AbcExporter::createShapeWriters(EvaluationContext *eval_ctx) { - Base *base = static_cast<Base *>(m_scene->base.first); - - while (base) { - Object *ob = base->object; - exploreObject(eval_ctx, ob, NULL); - - base = base->next; + for (Base *base = static_cast<Base *>(m_settings.sl->object_bases.first); base; base = base->next) { + exploreObject(eval_ctx, base, NULL); } } -void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Object *ob, Object *dupliObParent) +void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent) { /* If an object isn't exported itself, its duplilist shouldn't be * exported either. */ - if (!export_object(&m_settings, ob, dupliObParent != NULL)) { + if (!export_object(&m_settings, ob_base, dupliObParent != NULL)) { return; } - createShapeWriter(ob, dupliObParent); + createShapeWriter(ob_base, dupliObParent); + Object *ob = ob_base->object; ListBase *lb = object_duplilist(eval_ctx, m_scene, ob); if (lb) { + Base fake_base = *ob_base; // copy flags (like selection state) from the real object. + fake_base.next = fake_base.prev = NULL; + DupliObject *link = static_cast<DupliObject *>(lb->first); for (; link; link = link->next) { @@ -512,9 +516,9 @@ void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Object *ob, Object if (m_settings.renderable_only && link->no_draw) { continue; } - if (link->type == OB_DUPLIGROUP) { - exploreObject(eval_ctx, link->ob, ob); + fake_base.object = link->ob; + exploreObject(eval_ctx, &fake_base, ob); } } } @@ -537,16 +541,18 @@ void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *x if (m_settings.export_hair && psys->part->type == PART_HAIR) { m_settings.export_child_hairs = true; - m_shapes.push_back(new AbcHairWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys)); + m_shapes.push_back(new AbcHairWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys)); } else if (m_settings.export_particles && psys->part->type == PART_EMITTER) { - m_shapes.push_back(new AbcPointsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys)); + m_shapes.push_back(new AbcPointsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys)); } } } -void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent) +void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent) { + Object *ob = ob_base->object; + if (!object_type_is_exportable(ob)) { return; } @@ -578,7 +584,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent) return; } - m_shapes.push_back(new AbcMeshWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings)); + m_shapes.push_back(new AbcMeshWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings)); break; } case OB_SURF: @@ -589,7 +595,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent) return; } - m_shapes.push_back(new AbcNurbsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings)); + m_shapes.push_back(new AbcNurbsWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings)); break; } case OB_CURVE: @@ -600,7 +606,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent) return; } - m_shapes.push_back(new AbcCurveWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings)); + m_shapes.push_back(new AbcCurveWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings)); break; } case OB_CAMERA: @@ -608,7 +614,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent) Camera *cam = static_cast<Camera *>(ob->data); if (cam->type == CAM_PERSP) { - m_shapes.push_back(new AbcCameraWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings)); + m_shapes.push_back(new AbcCameraWriter(m_eval_ctx, m_scene, ob, xform, m_shape_sampling_index, m_settings)); } break; @@ -631,5 +637,5 @@ void AbcExporter::setCurrentFrame(Main *bmain, double t) { m_scene->r.cfra = static_cast<int>(t); m_scene->r.subframe = static_cast<float>(t) - m_scene->r.cfra; - BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, m_scene, m_scene->lay); + BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, m_scene); } diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h index f763922a73b..9c5fb69234c 100644 --- a/source/blender/alembic/intern/abc_exporter.h +++ b/source/blender/alembic/intern/abc_exporter.h @@ -38,11 +38,14 @@ struct EvaluationContext; struct Main; struct Object; struct Scene; +struct SceneLayer; +struct Base; struct ExportSettings { ExportSettings(); Scene *scene; + SceneLayer *sl; // Scene layer to export; all its objects will be exported, unless selected_only=true SimpleLogger logger; bool selected_only; @@ -87,6 +90,7 @@ class AbcExporter { unsigned int m_trans_sampling_index, m_shape_sampling_index; + EvaluationContext *m_eval_ctx; Scene *m_scene; ArchiveWriter *m_writer; @@ -98,7 +102,7 @@ class AbcExporter { std::vector<AbcObjectWriter *> m_shapes; public: - AbcExporter(Scene *scene, const char *filename, ExportSettings &settings); + AbcExporter(EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings); ~AbcExporter(); void operator()(Main *bmain, float &progress, bool &was_canceled); @@ -113,11 +117,11 @@ private: Alembic::Abc::TimeSamplingPtr createTimeSampling(double step); void createTransformWritersHierarchy(EvaluationContext *eval_ctx); - 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); + AbcTransformWriter * createTransformWriter(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent); + void exploreTransform(EvaluationContext *eval_ctx, Base *ob_base, Object *parent, Object *dupliObParent); + void exploreObject(EvaluationContext *eval_ctx, Base *ob_base, Object *dupliObParent); void createShapeWriters(EvaluationContext *eval_ctx); - void createShapeWriter(Object *ob, Object *dupliObParent); + void createShapeWriter(Base *ob_base, Object *dupliObParent); void createParticleSystemsWriters(Object *ob, AbcTransformWriter *xform); AbcTransformWriter *getXForm(const std::string &name); diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc index 8f8ed2019d5..2579aa3cc36 100644 --- a/source/blender/alembic/intern/abc_hair.cc +++ b/source/blender/alembic/intern/abc_hair.cc @@ -49,13 +49,14 @@ using Alembic::AbcGeom::OV2fGeomParam; /* ************************************************************************** */ -AbcHairWriter::AbcHairWriter(Scene *scene, +AbcHairWriter::AbcHairWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings, ParticleSystem *psys) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent) , m_uv_warning_shown(false) { m_psys = psys; @@ -76,7 +77,7 @@ void AbcHairWriter::do_write() return; } - DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH); + DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH); DM_ensure_tessface(dm); std::vector<Imath::V3f> verts; diff --git a/source/blender/alembic/intern/abc_hair.h b/source/blender/alembic/intern/abc_hair.h index 61f5fe361f8..8190c449205 100644 --- a/source/blender/alembic/intern/abc_hair.h +++ b/source/blender/alembic/intern/abc_hair.h @@ -40,7 +40,8 @@ class AbcHairWriter : public AbcObjectWriter { bool m_uv_warning_shown; public: - AbcHairWriter(Scene *scene, + AbcHairWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index 456d16b3e0d..b978fe971d6 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -38,7 +38,6 @@ extern "C" { #include "BLI_string.h" #include "BKE_cdderivedmesh.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mesh.h" @@ -287,12 +286,13 @@ static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob) /* ************************************************************************** */ -AbcMeshWriter::AbcMeshWriter(Scene *scene, +AbcMeshWriter::AbcMeshWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent) { m_is_animated = isAnimated(); m_subsurf_mod = NULL; @@ -520,7 +520,7 @@ DerivedMesh *AbcMeshWriter::getFinalMesh() m_subsurf_mod->mode |= eModifierMode_DisableTemporary; } - DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH); + DerivedMesh *dm = mesh_create_derived_render(m_eval_ctx, m_scene, m_object, CD_MASK_MESH); if (m_subsurf_mod) { m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary; @@ -918,12 +918,6 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type) numloops = dm->getNumLoops(dm); cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT, NULL, numloops, name); - if (cd_data_type == CD_MLOOPUV) { - CustomData_add_layer_named(dm->getPolyDataLayout(dm), - CD_MTEXPOLY, CD_DEFAULT, - NULL, numloops, name); - } - return cd_ptr; } diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h index 5c1eb01d8e0..e0b2365e134 100644 --- a/source/blender/alembic/intern/abc_mesh.h +++ b/source/blender/alembic/intern/abc_mesh.h @@ -50,7 +50,8 @@ class AbcMeshWriter : public AbcObjectWriter { bool m_is_subd; public: - AbcMeshWriter(Scene *scene, + AbcMeshWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc index eaef06fd6d1..0532191a28d 100644 --- a/source/blender/alembic/intern/abc_nurbs.cc +++ b/source/blender/alembic/intern/abc_nurbs.cc @@ -60,12 +60,13 @@ using Alembic::AbcGeom::ONuPatchSchema; /* ************************************************************************** */ -AbcNurbsWriter::AbcNurbsWriter(Scene *scene, +AbcNurbsWriter::AbcNurbsWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent) { m_is_animated = isAnimated(); diff --git a/source/blender/alembic/intern/abc_nurbs.h b/source/blender/alembic/intern/abc_nurbs.h index abe460a8988..3d20c5c60bb 100644 --- a/source/blender/alembic/intern/abc_nurbs.h +++ b/source/blender/alembic/intern/abc_nurbs.h @@ -32,7 +32,8 @@ class AbcNurbsWriter : public AbcObjectWriter { bool m_is_animated; public: - AbcNurbsWriter(Scene *scene, + AbcNurbsWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc index 6c4cb60d63c..98ebcf6debb 100644 --- a/source/blender/alembic/intern/abc_object.cc +++ b/source/blender/alembic/intern/abc_object.cc @@ -32,7 +32,6 @@ extern "C" { #include "DNA_space_types.h" /* for FILE_MAX */ #include "BKE_constraint.h" -#include "BKE_depsgraph.h" #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_modifier.h" @@ -59,13 +58,15 @@ using Alembic::AbcGeom::OStringProperty; /* ************************************************************************** */ -AbcObjectWriter::AbcObjectWriter(Scene *scene, +AbcObjectWriter::AbcObjectWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, uint32_t time_sampling, ExportSettings &settings, AbcObjectWriter *parent) : m_object(ob) , m_settings(settings) + , m_eval_ctx(eval_ctx) , m_scene(scene) , m_time_sampling(time_sampling) , m_first_frame(true) diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h index 852ef451f23..6aa6224f8d5 100644 --- a/source/blender/alembic/intern/abc_object.h +++ b/source/blender/alembic/intern/abc_object.h @@ -44,6 +44,7 @@ protected: Object *m_object; ExportSettings &m_settings; + EvaluationContext *m_eval_ctx; Scene *m_scene; uint32_t m_time_sampling; @@ -56,7 +57,8 @@ protected: std::string m_name; public: - AbcObjectWriter(Scene *scene, + AbcObjectWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, uint32_t time_sampling, ExportSettings &settings, diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc index 80567cd6bf0..feb2eff5b9d 100644 --- a/source/blender/alembic/intern/abc_points.cc +++ b/source/blender/alembic/intern/abc_points.cc @@ -58,13 +58,14 @@ using Alembic::AbcGeom::OPointsSchema; /* ************************************************************************** */ -AbcPointsWriter::AbcPointsWriter(Scene *scene, +AbcPointsWriter::AbcPointsWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings, ParticleSystem *psys) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(eval_ctx, scene, ob, time_sampling, settings, parent) { m_psys = psys; @@ -86,6 +87,7 @@ void AbcPointsWriter::do_write() ParticleKey state; ParticleSimulationData sim; + sim.eval_ctx = m_eval_ctx; sim.scene = m_scene; sim.ob = m_object; sim.psys = m_psys; diff --git a/source/blender/alembic/intern/abc_points.h b/source/blender/alembic/intern/abc_points.h index 369a802d763..b60f1997aa8 100644 --- a/source/blender/alembic/intern/abc_points.h +++ b/source/blender/alembic/intern/abc_points.h @@ -38,7 +38,8 @@ class AbcPointsWriter : public AbcObjectWriter { ParticleSystem *m_psys; public: - AbcPointsWriter(Scene *scene, + AbcPointsWriter(EvaluationContext *eval_ctx, + Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc index 5392387663f..0a1480e62b0 100644 --- a/source/blender/alembic/intern/abc_transform.cc +++ b/source/blender/alembic/intern/abc_transform.cc @@ -57,12 +57,13 @@ static bool has_parent_camera(Object *ob) /* ************************************************************************** */ -AbcTransformWriter::AbcTransformWriter(Object *ob, +AbcTransformWriter::AbcTransformWriter(EvaluationContext *eval_ctx, + Object *ob, const OObject &abc_parent, AbcTransformWriter *parent, unsigned int time_sampling, ExportSettings &settings) - : AbcObjectWriter(NULL, ob, time_sampling, settings, parent) + : AbcObjectWriter(eval_ctx, NULL, ob, time_sampling, settings, parent) , m_proxy_from(NULL) { m_is_animated = hasAnimation(m_object); diff --git a/source/blender/alembic/intern/abc_transform.h b/source/blender/alembic/intern/abc_transform.h index 753a4247e9f..e82765cb169 100644 --- a/source/blender/alembic/intern/abc_transform.h +++ b/source/blender/alembic/intern/abc_transform.h @@ -44,7 +44,8 @@ public: Object *m_proxy_from; public: - AbcTransformWriter(Object *ob, + AbcTransformWriter(EvaluationContext *eval_ctx, + Object *ob, const Alembic::AbcGeom::OObject &abc_parent, AbcTransformWriter *parent, unsigned int time_sampling, diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc index 26eb7620fb1..8601dff54ed 100644 --- a/source/blender/alembic/intern/abc_util.cc +++ b/source/blender/alembic/intern/abc_util.cc @@ -35,6 +35,7 @@ extern "C" { #include "DNA_object_types.h" +#include "DNA_layer_types.h" #include "BLI_math.h" @@ -60,6 +61,15 @@ std::string get_id_name(const ID * const id) return name; } +/** + * @brief get_object_dag_path_name returns the name under which the object + * will be exported in the Alembic file. It is of the form + * "[../grandparent/]parent/object" if dupli_parent is NULL, or + * "dupli_parent/[../grandparent/]parent/object" otherwise. + * @param ob + * @param dupli_parent + * @return + */ std::string get_object_dag_path_name(const Object * const ob, Object *dupli_parent) { std::string name = get_id_name(ob); @@ -78,31 +88,9 @@ std::string get_object_dag_path_name(const Object * const ob, Object *dupli_pare return name; } -bool object_selected(Object *ob) -{ - return ob->flag & SELECT; -} - -bool parent_selected(Object *ob) +bool object_selected(const Base * const ob_base) { - if (object_selected(ob)) { - return true; - } - - bool do_export = false; - - Object *parent = ob->parent; - - while (parent != NULL) { - if (object_selected(parent)) { - do_export = true; - break; - } - - parent = parent->parent; - } - - return do_export; + return ob_base->flag & SELECT; } Imath::M44d convert_matrix(float mat[4][4]) diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h index 2526958111a..fcc3b19c48b 100644 --- a/source/blender/alembic/intern/abc_util.h +++ b/source/blender/alembic/intern/abc_util.h @@ -48,13 +48,13 @@ struct ImportSettings; struct ID; struct Object; +struct Base; std::string get_id_name(const ID * const id); std::string get_id_name(const Object * const ob); std::string get_object_dag_path_name(const Object * const ob, Object *dupli_parent); -bool object_selected(Object *ob); -bool parent_selected(Object *ob); +bool object_selected(const Base * const ob_base); Imath::M44d convert_matrix(float mat[4][4]); diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index bee8e92e969..97a269b8fc0 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -48,12 +48,15 @@ extern "C" { #include "BKE_cdderivedmesh.h" #include "BKE_context.h" #include "BKE_curve.h" -#include "BKE_depsgraph.h" #include "BKE_global.h" +#include "BKE_layer.h" #include "BKE_library.h" #include "BKE_main.h" #include "BKE_scene.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + /* SpaceType struct has a member called 'new' which obviously conflicts with C++ * so temporarily redefining the new keyword to make it compile. */ #define new extern_new @@ -227,6 +230,7 @@ static void find_iobject(const IObject &object, IObject &ret, } struct ExportJobData { + EvaluationContext eval_ctx; Scene *scene; Main *bmain; @@ -259,7 +263,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo try { Scene *scene = data->scene; - AbcExporter exporter(scene, data->filename, data->settings); + AbcExporter exporter(&data->eval_ctx, scene, data->filename, data->settings); const int orig_frame = CFRA; @@ -269,8 +273,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo if (CFRA != orig_frame) { CFRA = orig_frame; - BKE_scene_update_for_newframe(data->bmain->eval_ctx, data->bmain, - scene, scene->lay); + BKE_scene_update_for_newframe(data->bmain->eval_ctx, data->bmain, scene); } data->export_ok = !data->was_canceled; @@ -308,6 +311,9 @@ bool ABC_export( bool as_background_job) { ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData")); + + CTX_data_eval_ctx(C, &job->eval_ctx); + job->scene = scene; job->bmain = CTX_data_main(C); job->export_ok = false; @@ -330,13 +336,24 @@ bool ABC_export( * hardcore refactoring. */ new (&job->settings) ExportSettings(); job->settings.scene = job->scene; + + /* Sybren: for now we only export the active scene layer. + * Later in the 2.8 development process this may be replaced by using + * a specific collection for Alembic I/O, which can then be toggled + * between "real" objects and cached Alembic files. */ + job->settings.sl = CTX_data_scene_layer(C); + job->settings.frame_start = params->frame_start; job->settings.frame_end = params->frame_end; job->settings.frame_samples_xform = params->frame_samples_xform; job->settings.frame_samples_shape = params->frame_samples_shape; job->settings.shutter_open = params->shutter_open; job->settings.shutter_close = params->shutter_close; + + /* Sybren: For now this is ignored, until we can get selection + * detection working through Base pointers (instead of ob->flags). */ job->settings.selected_only = params->selected_only; + job->settings.export_face_sets = params->face_sets; job->settings.export_normals = params->normals; job->settings.export_uvs = params->uvs; @@ -345,8 +362,13 @@ bool ABC_export( job->settings.export_particles = params->export_particles; job->settings.apply_subdiv = params->apply_subdiv; job->settings.flatten_hierarchy = params->flatten_hierarchy; + + /* Sybren: visible_layer & renderable only is ignored for now, + * to be replaced with collections later in the 2.8 dev process + * (also see note above). */ job->settings.visible_layers_only = params->visible_layers_only; job->settings.renderable_only = params->renderable_only; + job->settings.use_subdiv_schema = params->use_subdiv_schema; job->settings.export_ogawa = (params->compression_type == ABC_ARCHIVE_OGAWA); job->settings.pack_uv = params->packuv; @@ -606,6 +628,7 @@ enum { struct ImportJobData { Main *bmain; Scene *scene; + SceneLayer *scene_layer; char filename[1024]; ImportSettings settings; @@ -807,20 +830,32 @@ static void import_endjob(void *user_data) else { /* Add object to scene. */ Base *base; + LayerCollection *lc; + SceneLayer *sl = data->scene_layer; - BKE_scene_base_deselect_all(data->scene); + BKE_scene_layer_base_deselect_all(sl); + + lc = BKE_layer_collection_get_active(sl); + if (lc == NULL) { + BLI_assert(BLI_listbase_count_ex(&sl->layer_collections, 1) == 0); + /* when there is no collection linked to this SceneLayer, create one */ + SceneCollection *sc = BKE_collection_add(data->scene, NULL, NULL); + lc = BKE_collection_link(sl, sc); + } for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { Object *ob = (*iter)->object(); ob->lay = data->scene->lay; - base = BKE_scene_base_add(data->scene, ob); - BKE_scene_base_select(data->scene, base); + BKE_collection_object_add(data->scene, lc->scene_collection, ob); + + base = BKE_scene_layer_base_find(sl, ob); + BKE_scene_layer_base_select(sl, base); - DAG_id_tag_update_ex(data->bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DEG_id_tag_update_ex(data->bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } - DAG_relations_tag_update(data->bmain); + DEG_relations_tag_update(data->bmain); } for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { @@ -863,6 +898,7 @@ bool ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence ImportJobData *job = new ImportJobData(); job->bmain = CTX_data_main(C); job->scene = CTX_data_scene(C); + job->scene_layer = CTX_data_scene_layer(C); job->import_ok = false; BLI_strncpy(job->filename, filepath, 1024); |