diff options
Diffstat (limited to 'source/blender/alembic')
25 files changed, 554 insertions, 476 deletions
diff --git a/source/blender/alembic/ABC_alembic.h b/source/blender/alembic/ABC_alembic.h index 70250310213..08136fc2f49 100644 --- a/source/blender/alembic/ABC_alembic.h +++ b/source/blender/alembic/ABC_alembic.h @@ -29,8 +29,8 @@ extern "C" { struct bContext; struct CacheReader; -struct DerivedMesh; struct ListBase; +struct Mesh; struct Object; struct Scene; @@ -114,12 +114,13 @@ void ABC_get_transform(struct CacheReader *reader, float time, float scale); -struct DerivedMesh *ABC_read_mesh(struct CacheReader *reader, - struct Object *ob, - struct DerivedMesh *dm, - const float time, - const char **err_str, - int flags); +/* Either modifies current_mesh in-place or constructs a new mesh. */ +struct Mesh *ABC_read_mesh(struct CacheReader *reader, + struct Object *ob, + struct Mesh *current_mesh, + const float time, + const char **err_str, + int flags); void CacheReader_incref(struct CacheReader *reader); void CacheReader_free(struct CacheReader *reader); diff --git a/source/blender/alembic/CMakeLists.txt b/source/blender/alembic/CMakeLists.txt index fb08887c076..d3b5e189292 100644 --- a/source/blender/alembic/CMakeLists.txt +++ b/source/blender/alembic/CMakeLists.txt @@ -29,11 +29,11 @@ set(INC ../blenlib ../blenloader ../bmesh + ../depsgraph ../editors/include ../makesdna ../makesrna ../windowmanager - ../depsgraph ../../../intern/guardedalloc ../../../intern/utfconv ) diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc index 16416205983..457bbd2b3af 100644 --- a/source/blender/alembic/intern/abc_camera.cc +++ b/source/blender/alembic/intern/abc_camera.cc @@ -49,12 +49,11 @@ using Alembic::AbcGeom::kWrapExisting; /* ************************************************************************** */ -AbcCameraWriter::AbcCameraWriter(Scene *scene, - Object *ob, +AbcCameraWriter::AbcCameraWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(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..dd5dc28d598 100644 --- a/source/blender/alembic/intern/abc_camera.h +++ b/source/blender/alembic/intern/abc_camera.h @@ -35,8 +35,7 @@ class AbcCameraWriter : public AbcObjectWriter { Alembic::AbcGeom::OFloatProperty m_eye_separation; public: - AbcCameraWriter(Scene *scene, - Object *ob, + AbcCameraWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings); diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc index b0e2538e8bc..f9880eda451 100644 --- a/source/blender/alembic/intern/abc_curves.cc +++ b/source/blender/alembic/intern/abc_curves.cc @@ -37,8 +37,8 @@ extern "C" { #include "BLI_listbase.h" -#include "BKE_cdderivedmesh.h" #include "BKE_curve.h" +#include "BKE_mesh.h" #include "BKE_object.h" #include "ED_curve.h" @@ -71,12 +71,11 @@ using Alembic::AbcGeom::OV2fGeomParam; /* ************************************************************************** */ -AbcCurveWriter::AbcCurveWriter(Scene *scene, - Object *ob, +AbcCurveWriter::AbcCurveWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(ob, time_sampling, settings, parent) { OCurves curves(parent->alembicXform(), m_name, m_time_sampling); m_schema = curves.getSchema(); @@ -257,9 +256,21 @@ void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele /* ************************************************************************** */ -void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSelector &sample_sel) +void AbcCurveReader::read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSelector &sample_sel) { - ICurvesSchema::Sample smp = schema.getValue(sample_sel); + ICurvesSchema::Sample smp; + try { + smp = schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return; + } + const Int32ArraySamplePtr num_vertices = smp.getCurvesNumVertices(); const P3fArraySamplePtr positions = smp.getPositions(); const FloatArraySamplePtr weights = smp.getPositionWeights(); @@ -399,18 +410,31 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSele } } -/* NOTE: Alembic only stores data about control points, but the DerivedMesh +/* NOTE: Alembic only stores data about control points, but the Mesh * passed from the cache modifier contains the displist, which has more data * than the control points, so to avoid corrupting the displist we modify the - * object directly and create a new DerivedMesh from that. Also we might need to + * object directly and create a new Mesh from that. Also we might need to * create new or delete existing NURBS in the curve. */ -DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/, - const ISampleSelector &sample_sel, - int /*read_flag*/, - const char ** /*err_str*/) +Mesh *AbcCurveReader::read_mesh(Mesh *existing_mesh, + const ISampleSelector &sample_sel, + int /*read_flag*/, + const char **err_str) { - const ICurvesSchema::Sample sample = m_curves_schema.getValue(sample_sel); + ICurvesSchema::Sample sample; + + try { + sample = m_curves_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + *err_str = "Error reading curve sample; more detail on the console"; + printf("Alembic: error reading curve sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_curves_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return existing_mesh; + } const P3fArraySamplePtr &positions = sample.getPositions(); const Int32ArraySamplePtr num_vertices = sample.getCurvesNumVertices(); @@ -449,5 +473,5 @@ DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh * /*dm*/, } } - return CDDM_from_curve(m_object); + return BKE_mesh_new_nomain_from_curve(m_object); } diff --git a/source/blender/alembic/intern/abc_curves.h b/source/blender/alembic/intern/abc_curves.h index a9231f947b2..eb80553620d 100644 --- a/source/blender/alembic/intern/abc_curves.h +++ b/source/blender/alembic/intern/abc_curves.h @@ -36,8 +36,7 @@ class AbcCurveWriter : public AbcObjectWriter { Alembic::AbcGeom::OCurvesSchema::Sample m_sample; public: - AbcCurveWriter(Scene *scene, - Object *ob, + AbcCurveWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings); @@ -59,16 +58,17 @@ public: const char **err_str) const; void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel); - DerivedMesh *read_derivedmesh(DerivedMesh *dm, - const Alembic::Abc::ISampleSelector &sample_sel, - int read_flag, - const char **err_str); + struct Mesh *read_mesh(struct Mesh *existing_mesh, + const Alembic::Abc::ISampleSelector &sample_sel, + int read_flag, + const char **err_str); + + void read_curve_sample(Curve *cu, + const Alembic::AbcGeom::ICurvesSchema &schema, + const Alembic::Abc::ISampleSelector &sample_selector); + }; /* ************************************************************************** */ -void read_curve_sample(Curve *cu, - const Alembic::AbcGeom::ICurvesSchema &schema, - const Alembic::Abc::ISampleSelector &sample_selector); - #endif /* __ABC_CURVES_H__ */ diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index 6c1eeb9854f..d050f3b78b1 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -60,6 +60,8 @@ extern "C" { #include "BKE_modifier.h" #include "BKE_particle.h" #include "BKE_scene.h" + +#include "DEG_depsgraph_query.h" } using Alembic::Abc::TimeSamplingPtr; @@ -69,6 +71,8 @@ using Alembic::Abc::OBox3dProperty; ExportSettings::ExportSettings() : scene(NULL) + , view_layer(NULL) + , depsgraph(NULL) , logger() , selected_only(false) , visible_layers_only(false) @@ -111,7 +115,7 @@ static bool object_is_smoke_sim(Object *ob) return false; } -static bool object_type_is_exportable(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob) +static bool object_type_is_exportable(Scene *scene, Object *ob) { switch (ob->type) { case OB_MESH: @@ -126,7 +130,7 @@ static bool object_type_is_exportable(Main *bmain, EvaluationContext *eval_ctx, case OB_CAMERA: return true; case OB_MBALL: - return AbcMBallWriter::isBasisBall(bmain, eval_ctx, scene, ob); + return AbcMBallWriter::isBasisBall(scene, ob); default: return false; } @@ -136,45 +140,44 @@ static bool object_type_is_exportable(Main *bmain, EvaluationContext *eval_ctx, /** * 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_VISIBLE) == 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(Main *bmain, Scene *scene, const char *filename, ExportSettings &settings) +AbcExporter::AbcExporter(Main *bmain, const char *filename, ExportSettings &settings) : m_bmain(bmain) , m_settings(settings) , m_filename(filename) , m_trans_sampling_index(0) , m_shape_sampling_index(0) - , m_scene(scene) , m_writer(NULL) {} @@ -198,7 +201,7 @@ void AbcExporter::getShutterSamples(unsigned int nr_of_samples, bool time_relative, std::vector<double> &samples) { - Scene *scene = m_scene; /* for use in the FPS macro */ + Scene *scene = m_settings.scene; /* for use in the FPS macro */ samples.clear(); unsigned int frame_offset = time_relative ? m_settings.frame_start : 0; @@ -228,7 +231,7 @@ Alembic::Abc::TimeSamplingPtr AbcExporter::createTimeSampling(double step) Alembic::Abc::TimeSamplingType ts( static_cast<uint32_t>(samples.size()), - 1.0 / m_scene->r.frs_sec); + 1.0 / m_settings.scene->r.frs_sec); /* TODO(Sybren): shouldn't we use the FPS macro here? */ return TimeSamplingPtr(new Alembic::Abc::TimeSampling(ts, samples)); } @@ -249,20 +252,20 @@ void AbcExporter::getFrameSet(unsigned int nr_of_samples, } } -void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled) +void AbcExporter::operator()(float &progress, bool &was_canceled) { std::string scene_name; - if (bmain->name[0] != '\0') { + if (m_bmain->name[0] != '\0') { char scene_file_name[FILE_MAX]; - BLI_strncpy(scene_file_name, bmain->name, FILE_MAX); + BLI_strncpy(scene_file_name, m_bmain->name, FILE_MAX); scene_name = scene_file_name; } else { scene_name = "untitled"; } - Scene *scene = m_scene; + Scene *scene = m_settings.scene; const double fps = FPS; char buf[16]; snprintf(buf, 15, "%f", fps); @@ -294,8 +297,8 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled) OBox3dProperty archive_bounds_prop = Alembic::AbcGeom::CreateOArchiveBounds(m_writer->archive(), m_trans_sampling_index); - createTransformWritersHierarchy(bmain->eval_ctx); - createShapeWriters(bmain->eval_ctx); + createTransformWritersHierarchy(); + createShapeWriters(); /* Make a list of frames to export. */ @@ -328,7 +331,7 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled) const double frame = *begin; /* 'frame' is offset by start frame, so need to cancel the offset. */ - setCurrentFrame(bmain, frame); + setCurrentFrame(m_bmain, frame); if (shape_frames.count(frame) != 0) { for (int i = 0, e = m_shapes.size(); i != e; ++i) { @@ -357,42 +360,44 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled) } } -void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx) +void AbcExporter::createTransformWritersHierarchy() { - Base *base = static_cast<Base *>(m_scene->base.first); - - while (base) { + for (Base *base = static_cast<Base *>(m_settings.view_layer->object_bases.first); base; base = base->next) { Object *ob = base->object; - switch (ob->type) { - case OB_LAMP: - case OB_LATTICE: - 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_SPEAKER: + /* We do not export transforms for objects of these classes. */ + break; + default: + exploreTransform(base, ob->parent, NULL); + } } - - base = base->next; } } -void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent) +void AbcExporter::exploreTransform(Base *ob_base, Object *parent, 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; } - if (object_type_is_exportable(m_bmain, eval_ctx, m_scene, ob)) { + Object *ob = DEG_get_evaluated_object(m_settings.depsgraph, ob_base->object); + if (object_type_is_exportable(m_settings.scene, ob)) { createTransformWriter(ob, parent, dupliObParent); } - ListBase *lb = object_duplilist(m_bmain, eval_ctx, m_scene, ob); + ListBase *lb = object_duplilist(m_settings.depsgraph, m_settings.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,11 +408,12 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Obje continue; } - if (link->type == OB_DUPLIGROUP) { + if (link->type == OB_DUPLICOLLECTION) { 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(&fake_base, dupli_parent, ob); } } @@ -484,31 +490,30 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare return my_writer; } -void AbcExporter::createShapeWriters(EvaluationContext *eval_ctx) +void AbcExporter::createShapeWriters() { - 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.view_layer->object_bases.first); base; base = base->next) { + exploreObject(base, NULL); } } -void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Object *ob, Object *dupliObParent) +void AbcExporter::exploreObject(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; } + Object *ob = DEG_get_evaluated_object(m_settings.depsgraph, ob_base->object); createShapeWriter(ob, dupliObParent); - ListBase *lb = object_duplilist(m_bmain, eval_ctx, m_scene, ob); + ListBase *lb = object_duplilist(m_settings.depsgraph, m_settings.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) { @@ -516,9 +521,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); + if (link->type == OB_DUPLICOLLECTION) { + fake_base.object = link->ob; + exploreObject(&fake_base, ob); } } @@ -541,17 +546,17 @@ 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(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(ob, xform, m_shape_sampling_index, m_settings, psys)); } } } void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent) { - if (!object_type_is_exportable(m_bmain, m_bmain->eval_ctx, m_scene, ob)) { + if (!object_type_is_exportable(m_settings.scene, ob)) { return; } @@ -582,7 +587,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(ob, xform, m_shape_sampling_index, m_settings)); break; } case OB_SURF: @@ -593,7 +598,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(ob, xform, m_shape_sampling_index, m_settings)); break; } case OB_CURVE: @@ -604,7 +609,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(ob, xform, m_shape_sampling_index, m_settings)); break; } case OB_CAMERA: @@ -612,7 +617,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(ob, xform, m_shape_sampling_index, m_settings)); } break; @@ -625,7 +630,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent) } m_shapes.push_back(new AbcMBallWriter( - m_bmain, m_scene, ob, xform, + m_bmain, ob, xform, m_shape_sampling_index, m_settings)); break; } @@ -645,7 +650,7 @@ AbcTransformWriter *AbcExporter::getXForm(const std::string &name) 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); + m_settings.scene->r.cfra = static_cast<int>(t); + m_settings.scene->r.subframe = static_cast<float>(t) - m_settings.scene->r.cfra; + BKE_scene_graph_update_for_newframe(m_settings.depsgraph, bmain); } diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h index 280682b2896..a92e426292c 100644 --- a/source/blender/alembic/intern/abc_exporter.h +++ b/source/blender/alembic/intern/abc_exporter.h @@ -34,15 +34,19 @@ class AbcObjectWriter; class AbcTransformWriter; class ArchiveWriter; -struct EvaluationContext; +struct Depsgraph; struct Main; struct Object; struct Scene; +struct ViewLayer; +struct Base; struct ExportSettings { ExportSettings(); Scene *scene; + ViewLayer *view_layer; // Scene layer to export; all its objects will be exported, unless selected_only=true + Depsgraph *depsgraph; SimpleLogger logger; bool selected_only; @@ -88,8 +92,6 @@ class AbcExporter { unsigned int m_trans_sampling_index, m_shape_sampling_index; - Scene *m_scene; - ArchiveWriter *m_writer; /* mapping from name to transform writer */ @@ -99,10 +101,10 @@ class AbcExporter { std::vector<AbcObjectWriter *> m_shapes; public: - AbcExporter(Main *bmain, Scene *scene, const char *filename, ExportSettings &settings); + AbcExporter(Main *bmain, const char *filename, ExportSettings &settings); ~AbcExporter(); - void operator()(Main *bmain, float &progress, bool &was_canceled); + void operator()(float &progress, bool &was_canceled); protected: void getShutterSamples(unsigned int nr_of_samples, @@ -113,11 +115,11 @@ protected: private: Alembic::Abc::TimeSamplingPtr createTimeSampling(double step); - void createTransformWritersHierarchy(EvaluationContext *eval_ctx); + void createTransformWritersHierarchy(); 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); - void createShapeWriters(EvaluationContext *eval_ctx); + void exploreTransform(Base *ob_base, Object *parent, Object *dupliObParent); + void exploreObject(Base *ob_base, Object *dupliObParent); + void createShapeWriters(); void createShapeWriter(Object *ob, Object *dupliObParent); void createParticleSystemsWriters(Object *ob, AbcTransformWriter *xform); diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc index 0208da8a6d7..83a46a330fd 100644 --- a/source/blender/alembic/intern/abc_hair.cc +++ b/source/blender/alembic/intern/abc_hair.cc @@ -30,12 +30,16 @@ extern "C" { #include "MEM_guardedalloc.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "BLI_listbase.h" #include "BLI_math_geom.h" -#include "BKE_DerivedMesh.h" +#include "BKE_library.h" +#include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_object.h" #include "BKE_particle.h" } @@ -49,13 +53,12 @@ using Alembic::AbcGeom::OV2fGeomParam; /* ************************************************************************** */ -AbcHairWriter::AbcHairWriter(Scene *scene, - Object *ob, +AbcHairWriter::AbcHairWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings, ParticleSystem *psys) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(ob, time_sampling, settings, parent) , m_uv_warning_shown(false) { m_psys = psys; @@ -69,15 +72,8 @@ void AbcHairWriter::do_write() if (!m_psys) { return; } - - ParticleSystemModifierData *psmd = psys_get_modifier(m_object, m_psys); - - if (!psmd->dm_final) { - return; - } - - DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH); - DM_ensure_tessface(dm); + Mesh *mesh = mesh_get_eval_final(m_settings.depsgraph, m_settings.scene, m_object, CD_MASK_MESH); + BKE_mesh_tessface_ensure(mesh); std::vector<Imath::V3f> verts; std::vector<int32_t> hvertices; @@ -87,15 +83,13 @@ void AbcHairWriter::do_write() if (m_psys->pathcache) { ParticleSettings *part = m_psys->part; - write_hair_sample(dm, part, verts, norm_values, uv_values, hvertices); + write_hair_sample(mesh, part, verts, norm_values, uv_values, hvertices); if (m_settings.export_child_hairs && m_psys->childcache) { - write_hair_child_sample(dm, part, verts, norm_values, uv_values, hvertices); + write_hair_child_sample(mesh, part, verts, norm_values, uv_values, hvertices); } } - dm->release(dm); - Alembic::Abc::P3fArraySample iPos(verts); m_sample = OCurvesSchema::Sample(iPos, hvertices); m_sample.setBasis(Alembic::AbcGeom::kNoBasis); @@ -118,7 +112,7 @@ void AbcHairWriter::do_write() m_schema.set(m_sample); } -void AbcHairWriter::write_hair_sample(DerivedMesh *dm, +void AbcHairWriter::write_hair_sample(Mesh *mesh, ParticleSettings *part, std::vector<Imath::V3f> &verts, std::vector<Imath::V3f> &norm_values, @@ -129,9 +123,9 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm, float inv_mat[4][4]; invert_m4_m4_safe(inv_mat, m_object->obmat); - MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer(&dm->faceData, CD_MTFACE)); - MFace *mface = dm->getTessFaceArray(dm); - MVert *mverts = dm->getVertArray(dm); + MTFace *mtface = mesh->mtface; + MFace *mface = mesh->mface; + MVert *mverts = mesh->mvert; if ((!mtface || !mface) && !m_uv_warning_shown) { std::fprintf(stderr, "Warning, no UV set found for underlying geometry of %s.\n", @@ -151,11 +145,13 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm, /* underlying info for faces-only emission */ path = cache[p]; + /* Write UV and normal vectors */ if (part->from == PART_FROM_FACE && mtface) { const int num = pa->num_dmcache >= 0 ? pa->num_dmcache : pa->num; - if (num < dm->getNumTessFaces(dm)) { - MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, num, CD_MFACE)); + if (num < mesh->totface) { + /* TODO(Sybren): check whether the NULL check here and if(mface) are actually required */ + MFace *face = mface == NULL ? NULL : &mface[num]; MTFace *tface = mtface + num; if (mface) { @@ -164,14 +160,14 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm, psys_interpolate_uvs(tface, face->v4, pa->fuv, r_uv); uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1])); - psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, normal, NULL, NULL, NULL, NULL); + psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, normal, NULL, NULL, NULL); copy_yup_from_zup(tmp_nor.getValue(), normal); norm_values.push_back(tmp_nor); } } else { - std::fprintf(stderr, "Particle to faces overflow (%d/%d)\n", num, dm->getNumTessFaces(dm)); + std::fprintf(stderr, "Particle to faces overflow (%d/%d)\n", num, mesh->totface); } } else if (part->from == PART_FROM_VERT && mtface) { @@ -179,8 +175,8 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm, const int num = (pa->num_dmcache >= 0) ? pa->num_dmcache : pa->num; /* iterate over all faces to find a corresponding underlying UV */ - for (int n = 0; n < dm->getNumTessFaces(dm); ++n) { - MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, n, CD_MFACE)); + for (int n = 0; n < mesh->totface; ++n) { + MFace *face = &mface[n]; MTFace *tface = mtface + n; unsigned int vtx[4]; vtx[0] = face->v1; @@ -216,7 +212,7 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm, int steps = path->segments + 1; hvertices.push_back(steps); - for (k = 0; k < steps; ++k) { + for (k = 0; k < steps; ++k, ++path) { float vert[3]; copy_v3_v3(vert, path->co); mul_m4_v3(inv_mat, vert); @@ -224,12 +220,11 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm, /* Convert Z-up to Y-up. */ verts.push_back(Imath::V3f(vert[0], vert[2], -vert[1])); - ++path; } } } -void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm, +void AbcHairWriter::write_hair_child_sample(Mesh *mesh, ParticleSettings *part, std::vector<Imath::V3f> &verts, std::vector<Imath::V3f> &norm_values, @@ -240,8 +235,8 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm, float inv_mat[4][4]; invert_m4_m4_safe(inv_mat, m_object->obmat); - MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer(&dm->faceData, CD_MTFACE)); - MVert *mverts = dm->getVertArray(dm); + MTFace *mtface = mesh->mtface; + MVert *mverts = mesh->mvert; ParticleCacheKey **cache = m_psys->childcache; ParticleCacheKey *path; @@ -264,7 +259,7 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm, continue; } - MFace *face = static_cast<MFace *>(dm->getTessFaceData(dm, num, CD_MFACE)); + MFace *face = &mesh->mface[num]; MTFace *tface = mtface + num; float r_uv[2], tmpnor[3], mapfw[4], vec[3]; @@ -272,7 +267,7 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm, psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv); uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1])); - psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL, NULL); + psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL); /* Convert Z-up to Y-up. */ norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1])); diff --git a/source/blender/alembic/intern/abc_hair.h b/source/blender/alembic/intern/abc_hair.h index 61f5fe361f8..e2dffd4edaf 100644 --- a/source/blender/alembic/intern/abc_hair.h +++ b/source/blender/alembic/intern/abc_hair.h @@ -25,7 +25,6 @@ #include "abc_object.h" -struct DerivedMesh; struct ParticleSettings; struct ParticleSystem; @@ -40,8 +39,7 @@ class AbcHairWriter : public AbcObjectWriter { bool m_uv_warning_shown; public: - AbcHairWriter(Scene *scene, - Object *ob, + AbcHairWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings, @@ -50,14 +48,14 @@ public: private: virtual void do_write(); - void write_hair_sample(DerivedMesh *dm, + void write_hair_sample(struct Mesh *mesh, ParticleSettings *part, std::vector<Imath::V3f> &verts, std::vector<Imath::V3f> &norm_values, std::vector<Imath::V2f> &uv_values, std::vector<int32_t> &hvertices); - void write_hair_child_sample(DerivedMesh *dm, + void write_hair_child_sample(struct Mesh *mesh, ParticleSettings *part, std::vector<Imath::V3f> &verts, std::vector<Imath::V3f> &norm_values, diff --git a/source/blender/alembic/intern/abc_mball.cc b/source/blender/alembic/intern/abc_mball.cc index 05700e6024e..62ab561274a 100644 --- a/source/blender/alembic/intern/abc_mball.cc +++ b/source/blender/alembic/intern/abc_mball.cc @@ -30,7 +30,6 @@ extern "C" { #include "DNA_object_types.h" #include "BKE_curve.h" -#include "BKE_depsgraph.h" #include "BKE_displist.h" #include "BKE_main.h" #include "BKE_mball.h" @@ -43,23 +42,21 @@ extern "C" { AbcMBallWriter::AbcMBallWriter( Main *bmain, - Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(ob, time_sampling, settings, parent) , m_bmain(bmain) { m_is_animated = isAnimated(); m_mesh_ob = BKE_object_copy(bmain, ob); - m_mesh_ob->curve_cache = (CurveCache *)MEM_callocN( + m_mesh_ob->runtime.curve_cache = (CurveCache *)MEM_callocN( sizeof(CurveCache), "CurveCache for AbcMBallWriter"); - m_mesh_writer = new AbcMeshWriter(scene, m_mesh_ob, parent, - time_sampling, settings); + m_mesh_writer = new AbcMeshWriter(m_mesh_ob, parent, time_sampling, settings); m_mesh_writer->setIsAnimated(m_is_animated); } @@ -97,13 +94,11 @@ void AbcMBallWriter::do_write() id_us_min(&tmpmesh->id); ListBase disp = {NULL, NULL}; - /* TODO(sergey): This is gonna to work for until EvaluationContext + /* TODO(sergey): This is gonna to work for until Depsgraph * only contains for_render flag. As soon as CoW is * implemented, this is to be rethinked. */ - EvaluationContext eval_ctx; - DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_RENDER); - BKE_displist_make_mball_forRender(m_bmain, &eval_ctx, m_scene, m_object, &disp); + BKE_displist_make_mball_forRender(m_settings.depsgraph, m_settings.scene, m_object, &disp); BKE_mesh_from_metaball(&disp, tmpmesh); BKE_displist_free(&disp); @@ -115,8 +110,8 @@ void AbcMBallWriter::do_write() m_mesh_ob->data = NULL; } -bool AbcMBallWriter::isBasisBall(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob) +bool AbcMBallWriter::isBasisBall(Scene *scene, Object *ob) { - Object *basis_ob = BKE_mball_basis_find(bmain, eval_ctx, scene, ob); + Object *basis_ob = BKE_mball_basis_find(scene, ob); return ob == basis_ob; } diff --git a/source/blender/alembic/intern/abc_mball.h b/source/blender/alembic/intern/abc_mball.h index 46567ff3386..07cb1908e95 100644 --- a/source/blender/alembic/intern/abc_mball.h +++ b/source/blender/alembic/intern/abc_mball.h @@ -43,7 +43,6 @@ class AbcMBallWriter : public AbcObjectWriter { public: AbcMBallWriter( Main *bmain, - Scene *scene, Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, @@ -51,7 +50,7 @@ public: ~AbcMBallWriter(); - static bool isBasisBall(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Object *ob); + static bool isBasisBall(Scene *scene, Object *ob); private: virtual void do_write(); diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index a2903f7c3d1..2b739837239 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -30,6 +30,7 @@ extern "C" { #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_object_fluidsim_types.h" #include "DNA_object_types.h" @@ -37,11 +38,10 @@ extern "C" { #include "BLI_math_geom.h" #include "BLI_string.h" -#include "BKE_cdderivedmesh.h" -#include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -52,6 +52,8 @@ extern "C" { #include "bmesh.h" #include "bmesh_tools.h" + +#include "DEG_depsgraph_query.h" } using Alembic::Abc::FloatArraySample; @@ -104,27 +106,27 @@ using Alembic::AbcGeom::IN3fGeomParam; /* NOTE: Alembic's polygon winding order is clockwise, to match with Renderman. */ -static void get_vertices(DerivedMesh *dm, std::vector<Imath::V3f> &points) +static void get_vertices(struct Mesh *mesh, std::vector<Imath::V3f> &points) { points.clear(); - points.resize(dm->getNumVerts(dm)); + points.resize(mesh->totvert); - MVert *verts = dm->getVertArray(dm); + MVert *verts = mesh->mvert; - for (int i = 0, e = dm->getNumVerts(dm); i < e; ++i) { + for (int i = 0, e = mesh->totvert; i < e; ++i) { copy_yup_from_zup(points[i].getValue(), verts[i].co); } } -static void get_topology(DerivedMesh *dm, +static void get_topology(struct Mesh *mesh, std::vector<int32_t> &poly_verts, std::vector<int32_t> &loop_counts, bool &smooth_normal) { - const int num_poly = dm->getNumPolys(dm); - const int num_loops = dm->getNumLoops(dm); - MLoop *mloop = dm->getLoopArray(dm); - MPoly *mpoly = dm->getPolyArray(dm); + const int num_poly = mesh->totpoly; + const int num_loops = mesh->totloop; + MLoop *mloop = mesh->mloop; + MPoly *mpoly = mesh->mpoly; poly_verts.clear(); loop_counts.clear(); @@ -146,7 +148,7 @@ static void get_topology(DerivedMesh *dm, } } -static void get_creases(DerivedMesh *dm, +static void get_creases(struct Mesh *mesh, std::vector<int32_t> &indices, std::vector<int32_t> &lengths, std::vector<float> &sharpnesses) @@ -157,9 +159,9 @@ static void get_creases(DerivedMesh *dm, lengths.clear(); sharpnesses.clear(); - MEdge *edge = dm->getEdgeArray(dm); + MEdge *edge = mesh->medge; - for (int i = 0, e = dm->getNumEdges(dm); i < e; ++i) { + for (int i = 0, e = mesh->totedge; i < e; ++i) { const float sharpness = static_cast<float>(edge[i].crease) * factor; if (sharpness != 0.0f) { @@ -172,41 +174,40 @@ static void get_creases(DerivedMesh *dm, lengths.resize(sharpnesses.size(), 2); } -static void get_vertex_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals) +static void get_vertex_normals(struct Mesh *mesh, std::vector<Imath::V3f> &normals) { normals.clear(); - normals.resize(dm->getNumVerts(dm)); + normals.resize(mesh->totvert); - MVert *verts = dm->getVertArray(dm); + MVert *verts = mesh->mvert; float no[3]; - for (int i = 0, e = dm->getNumVerts(dm); i < e; ++i) { + for (int i = 0, e = mesh->totvert; i < e; ++i) { normal_short_to_float_v3(no, verts[i].no); copy_yup_from_zup(normals[i].getValue(), no); } } -static void get_loop_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals) +static void get_loop_normals(struct Mesh *mesh, std::vector<Imath::V3f> &normals) { - MPoly *mpoly = dm->getPolyArray(dm); - MPoly *mp = mpoly; + MPoly *mp = mesh->mpoly; - MLoop *mloop = dm->getLoopArray(dm); + MLoop *mloop = mesh->mloop; MLoop *ml = mloop; - MVert *verts = dm->getVertArray(dm); + MVert *verts = mesh->mvert; - const float (*lnors)[3] = static_cast<float(*)[3]>(dm->getLoopDataArray(dm, CD_NORMAL)); + const float (*lnors)[3] = static_cast<float(*)[3]>(CustomData_get_layer(&mesh->ldata, CD_NORMAL)); normals.clear(); - normals.resize(dm->getNumLoops(dm)); + normals.resize(mesh->totloop); unsigned loop_index = 0; /* NOTE: data needs to be written in the reverse order. */ if (lnors) { - for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i, ++mp) { + for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mp) { ml = mloop + mp->loopstart + (mp->totloop - 1); for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) { @@ -218,7 +219,7 @@ static void get_loop_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals) else { float no[3]; - for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i, ++mp) { + for (int i = 0, e = mesh->totpoly; i < e; ++i, ++mp) { ml = mloop + mp->loopstart + (mp->totloop - 1); /* Flat shaded, use common normal for all verts. */ @@ -287,12 +288,11 @@ static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob) /* ************************************************************************** */ -AbcMeshWriter::AbcMeshWriter(Scene *scene, - Object *ob, +AbcMeshWriter::AbcMeshWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(ob, time_sampling, settings, parent) { m_is_animated = isAnimated(); m_subsurf_mod = NULL; @@ -304,11 +304,11 @@ AbcMeshWriter::AbcMeshWriter(Scene *scene, } if (!m_settings.apply_subdiv) { - m_subsurf_mod = get_subsurf_modifier(m_scene, m_object); + m_subsurf_mod = get_subsurf_modifier(m_settings.scene, m_object); m_is_subd = (m_subsurf_mod != NULL); } - m_is_liquid = (get_liquid_sim_modifier(m_scene, m_object) != NULL); + m_is_liquid = (get_liquid_sim_modifier(m_settings.scene, m_object) != NULL); while (parent->alembicXform().getChildHeader(m_name)) { m_name.append("_"); @@ -369,36 +369,37 @@ void AbcMeshWriter::do_write() if (!m_first_frame && !m_is_animated) return; - DerivedMesh *dm = getFinalMesh(); + bool needsfree; + struct Mesh *mesh = getFinalMesh(needsfree); try { if (m_settings.use_subdiv_schema && m_subdiv_schema.valid()) { - writeSubD(dm); + writeSubD(mesh); } else { - writeMesh(dm); + writeMesh(mesh); } - freeMesh(dm); + if (needsfree) BKE_id_free(NULL, mesh); } catch (...) { - freeMesh(dm); + if (needsfree) BKE_id_free(NULL, mesh); throw; } } -void AbcMeshWriter::writeMesh(DerivedMesh *dm) +void AbcMeshWriter::writeMesh(struct Mesh *mesh) { std::vector<Imath::V3f> points, normals; std::vector<int32_t> poly_verts, loop_counts; bool smooth_normal = false; - get_vertices(dm, points); - get_topology(dm, poly_verts, loop_counts, smooth_normal); + get_vertices(mesh, points); + get_topology(mesh, poly_verts, loop_counts, smooth_normal); if (m_first_frame && m_settings.export_face_sets) { - writeFaceSets(dm, m_mesh_schema); + writeFaceSets(mesh, m_mesh_schema); } m_mesh_sample = OPolyMeshSchema::Sample(V3fArraySample(points), @@ -407,7 +408,7 @@ void AbcMeshWriter::writeMesh(DerivedMesh *dm) UVSample sample; if (m_first_frame && m_settings.export_uvs) { - const char *name = get_uv_sample(sample, m_custom_data_config, &dm->loopData); + const char *name = get_uv_sample(sample, m_custom_data_config, &mesh->ldata); if (!sample.indices.empty() && !sample.uvs.empty()) { OV2fGeomParam::Sample uv_sample; @@ -419,15 +420,15 @@ void AbcMeshWriter::writeMesh(DerivedMesh *dm) m_mesh_sample.setUVs(uv_sample); } - write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &dm->loopData, CD_MLOOPUV); + write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &mesh->ldata, CD_MLOOPUV); } if (m_settings.export_normals) { if (smooth_normal) { - get_loop_normals(dm, normals); + get_loop_normals(mesh, normals); } else { - get_vertex_normals(dm, normals); + get_vertex_normals(mesh, normals); } ON3fGeomParam::Sample normals_sample; @@ -441,7 +442,7 @@ void AbcMeshWriter::writeMesh(DerivedMesh *dm) if (m_is_liquid) { std::vector<Imath::V3f> velocities; - getVelocities(dm, velocities); + getVelocities(mesh, velocities); m_mesh_sample.setVelocities(V3fArraySample(velocities)); } @@ -450,10 +451,10 @@ void AbcMeshWriter::writeMesh(DerivedMesh *dm) m_mesh_schema.set(m_mesh_sample); - writeArbGeoParams(dm); + writeArbGeoParams(mesh); } -void AbcMeshWriter::writeSubD(DerivedMesh *dm) +void AbcMeshWriter::writeSubD(struct Mesh *mesh) { std::vector<float> crease_sharpness; std::vector<Imath::V3f> points; @@ -462,12 +463,12 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm) bool smooth_normal = false; - get_vertices(dm, points); - get_topology(dm, poly_verts, loop_counts, smooth_normal); - get_creases(dm, crease_indices, crease_lengths, crease_sharpness); + get_vertices(mesh, points); + get_topology(mesh, poly_verts, loop_counts, smooth_normal); + get_creases(mesh, crease_indices, crease_lengths, crease_sharpness); if (m_first_frame && m_settings.export_face_sets) { - writeFaceSets(dm, m_subdiv_schema); + writeFaceSets(mesh, m_subdiv_schema); } m_subdiv_sample = OSubDSchema::Sample(V3fArraySample(points), @@ -476,7 +477,7 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm) UVSample sample; if (m_first_frame && m_settings.export_uvs) { - const char *name = get_uv_sample(sample, m_custom_data_config, &dm->loopData); + const char *name = get_uv_sample(sample, m_custom_data_config, &mesh->ldata); if (!sample.indices.empty() && !sample.uvs.empty()) { OV2fGeomParam::Sample uv_sample; @@ -488,7 +489,7 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm) m_subdiv_sample.setUVs(uv_sample); } - write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &dm->loopData, CD_MLOOPUV); + write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &mesh->ldata, CD_MLOOPUV); } if (!crease_indices.empty()) { @@ -500,11 +501,11 @@ void AbcMeshWriter::writeSubD(DerivedMesh *dm) m_subdiv_sample.setSelfBounds(bounds()); m_subdiv_schema.set(m_subdiv_sample); - writeArbGeoParams(dm); + writeArbGeoParams(mesh); } template <typename Schema> -void AbcMeshWriter::writeFaceSets(DerivedMesh *dm, Schema &schema) +void AbcMeshWriter::writeFaceSets(struct Mesh *dm, Schema &schema) { std::map< std::string, std::vector<int32_t> > geo_groups; getGeoGroups(dm, geo_groups); @@ -518,14 +519,17 @@ void AbcMeshWriter::writeFaceSets(DerivedMesh *dm, Schema &schema) } } -DerivedMesh *AbcMeshWriter::getFinalMesh() +Mesh *AbcMeshWriter::getFinalMesh(bool &r_needsfree) { /* We don't want subdivided mesh data */ if (m_subsurf_mod) { m_subsurf_mod->mode |= eModifierMode_DisableTemporary; } - DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH); + Scene *scene = DEG_get_evaluated_scene(m_settings.depsgraph); + Object *ob_eval = DEG_get_evaluated_object(m_settings.depsgraph, m_object); + struct Mesh *mesh = mesh_get_eval_final(m_settings.depsgraph, scene, ob_eval, CD_MASK_MESH); + r_needsfree = false; if (m_subsurf_mod) { m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary; @@ -536,34 +540,31 @@ DerivedMesh *AbcMeshWriter::getFinalMesh() const int quad_method = m_settings.quad_method; const int ngon_method = m_settings.ngon_method; - BMesh *bm = DM_to_bmesh(dm, true); + struct BMeshCreateParams bmcp = {false}; + struct BMeshFromMeshParams bmfmp = {true, false, false, 0}; + BMesh *bm = BKE_mesh_to_bmesh_ex(mesh, &bmcp, &bmfmp); BM_mesh_triangulate(bm, quad_method, ngon_method, tag_only, NULL, NULL, NULL); - DerivedMesh *result = CDDM_from_bmesh(bm, false); + struct BMeshToMeshParams bmmp = {0}; + Mesh *result = BKE_bmesh_to_mesh_nomain(bm, &bmmp); BM_mesh_free(bm); - freeMesh(dm); - - dm = result; + mesh = result; + r_needsfree = true; } m_custom_data_config.pack_uvs = m_settings.pack_uv; - m_custom_data_config.mpoly = dm->getPolyArray(dm); - m_custom_data_config.mloop = dm->getLoopArray(dm); - m_custom_data_config.totpoly = dm->getNumPolys(dm); - m_custom_data_config.totloop = dm->getNumLoops(dm); - m_custom_data_config.totvert = dm->getNumVerts(dm); + m_custom_data_config.mpoly = mesh->mpoly; + m_custom_data_config.mloop = mesh->mloop; + m_custom_data_config.totpoly = mesh->totpoly; + m_custom_data_config.totloop = mesh->totloop; + m_custom_data_config.totvert = mesh->totvert; - return dm; -} - -void AbcMeshWriter::freeMesh(DerivedMesh *dm) -{ - dm->release(dm); + return mesh; } -void AbcMeshWriter::writeArbGeoParams(DerivedMesh *dm) +void AbcMeshWriter::writeArbGeoParams(struct Mesh *dm) { if (m_is_liquid) { /* We don't need anything more for liquid meshes. */ @@ -572,22 +573,22 @@ void AbcMeshWriter::writeArbGeoParams(DerivedMesh *dm) if (m_first_frame && m_settings.export_vcols) { if (m_subdiv_schema.valid()) { - write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &dm->loopData, CD_MLOOPCOL); + write_custom_data(m_subdiv_schema.getArbGeomParams(), m_custom_data_config, &dm->ldata, CD_MLOOPCOL); } else { - write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &dm->loopData, CD_MLOOPCOL); + write_custom_data(m_mesh_schema.getArbGeomParams(), m_custom_data_config, &dm->ldata, CD_MLOOPCOL); } } } -void AbcMeshWriter::getVelocities(DerivedMesh *dm, std::vector<Imath::V3f> &vels) +void AbcMeshWriter::getVelocities(struct Mesh *mesh, std::vector<Imath::V3f> &vels) { - const int totverts = dm->getNumVerts(dm); + const int totverts = mesh->totvert; vels.clear(); vels.resize(totverts); - ModifierData *md = get_liquid_sim_modifier(m_scene, m_object); + ModifierData *md = get_liquid_sim_modifier(m_settings.scene, m_object); FluidsimModifierData *fmd = reinterpret_cast<FluidsimModifierData *>(md); FluidsimSettings *fss = fmd->fss; @@ -605,11 +606,11 @@ void AbcMeshWriter::getVelocities(DerivedMesh *dm, std::vector<Imath::V3f> &vels } void AbcMeshWriter::getGeoGroups( - DerivedMesh *dm, + struct Mesh *mesh, std::map<std::string, std::vector<int32_t> > &geo_groups) { - const int num_poly = dm->getNumPolys(dm); - MPoly *polygons = dm->getPolyArray(dm); + const int num_poly = mesh->totpoly; + MPoly *polygons = mesh->mpoly; for (int i = 0; i < num_poly; ++i) { MPoly ¤t_poly = polygons[i]; @@ -638,7 +639,7 @@ void AbcMeshWriter::getGeoGroups( std::vector<int32_t> faceArray; - for (int i = 0, e = dm->getNumTessFaces(dm); i < e; ++i) { + for (int i = 0, e = mesh->totface; i < e; ++i) { faceArray.push_back(i); } @@ -873,11 +874,11 @@ ABC_INLINE void read_normals_params(AbcMeshData &abc_data, } } -static bool check_smooth_poly_flag(DerivedMesh *dm) +static bool check_smooth_poly_flag(Mesh *mesh) { - MPoly *mpolys = dm->getPolyArray(dm); + MPoly *mpolys = mesh->mpoly; - for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i) { + for (int i = 0, e = mesh->totpoly; i < e; ++i) { MPoly &poly = mpolys[i]; if ((poly.flag & ME_SMOOTH) != 0) { @@ -888,11 +889,11 @@ static bool check_smooth_poly_flag(DerivedMesh *dm) return false; } -static void set_smooth_poly_flag(DerivedMesh *dm) +static void set_smooth_poly_flag(Mesh *mesh) { - MPoly *mpolys = dm->getPolyArray(dm); + MPoly *mpolys = mesh->mpoly; - for (int i = 0, e = dm->getNumPolys(dm); i < e; ++i) { + for (int i = 0, e = mesh->totpoly; i < e; ++i) { MPoly &poly = mpolys[i]; poly.flag |= ME_SMOOTH; } @@ -900,7 +901,7 @@ static void set_smooth_poly_flag(DerivedMesh *dm) static void *add_customdata_cb(void *user_data, const char *name, int data_type) { - DerivedMesh *dm = static_cast<DerivedMesh *>(user_data); + Mesh *mesh = static_cast<Mesh *>(user_data); CustomDataType cd_data_type = static_cast<CustomDataType>(data_type); void *cd_ptr; CustomData *loopdata; @@ -911,7 +912,7 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type) return NULL; } - loopdata = dm->getLoopDataLayout(dm); + loopdata = &mesh->ldata; cd_ptr = CustomData_get_layer_named(loopdata, cd_data_type, name); if (cd_ptr != NULL) { /* layer already exists, so just return it. */ @@ -920,15 +921,9 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type) /* create a new layer, taking care to construct the hopefully-soon-to-be-removed * CD_MTEXPOLY layer too, with the same name. */ - numloops = dm->getNumLoops(dm); + numloops = mesh->totloop; 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; } @@ -992,17 +987,19 @@ static void read_mesh_sample(const std::string & iobject_full_name, } } -CDStreamConfig get_config(DerivedMesh *dm) +CDStreamConfig get_config(Mesh *mesh) { CDStreamConfig config; - config.user_data = dm; - config.mvert = dm->getVertArray(dm); - config.mloop = dm->getLoopArray(dm); - config.mpoly = dm->getPolyArray(dm); - config.totloop = dm->getNumLoops(dm); - config.totpoly = dm->getNumPolys(dm); - config.loopdata = dm->getLoopDataLayout(dm); + BLI_assert(mesh->mvert); + + config.user_data = mesh; + config.mvert = mesh->mvert; + config.mloop = mesh->mloop; + config.mpoly = mesh->mpoly; + config.totloop = mesh->totloop; + config.totpoly = mesh->totpoly; + config.loopdata = &mesh->ldata; config.add_customdata_cb = add_customdata_cb; return config; @@ -1033,14 +1030,8 @@ void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str()); m_object->data = mesh; - DerivedMesh *dm = CDDM_from_mesh(mesh); - DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, MOD_MESHSEQ_READ_ALL, NULL); - - if (ndm != dm) { - dm->release(dm); - } - - DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true); + Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL); + BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true); if (m_settings->validate_meshes) { BKE_mesh_validate(mesh, false, false); @@ -1070,33 +1061,45 @@ bool AbcMeshReader::accepts_object_type(const Alembic::AbcCoreAbstract::ObjectHe return true; } -DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm, - const ISampleSelector &sample_sel, - int read_flag, - const char **err_str) +Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh, + const ISampleSelector &sample_sel, + int read_flag, + const char **err_str) { - const IPolyMeshSchema::Sample sample = m_schema.getValue(sample_sel); + IPolyMeshSchema::Sample sample; + try { + sample = m_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + *err_str = "Error reading mesh sample; more detail on the console"; + printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return existing_mesh; + } const P3fArraySamplePtr &positions = sample.getPositions(); const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices(); const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts(); - DerivedMesh *new_dm = NULL; + Mesh *new_mesh = NULL; /* Only read point data when streaming meshes, unless we need to create new ones. */ ImportSettings settings; settings.read_flag |= read_flag; - bool topology_changed = positions->size() != dm->getNumVerts(dm) || - face_counts->size() != dm->getNumPolys(dm) || - face_indices->size() != dm->getNumLoops(dm); + bool topology_changed = positions->size() != existing_mesh->totvert || + face_counts->size() != existing_mesh->totpoly || + face_indices->size() != existing_mesh->totloop; if (topology_changed) { - new_dm = CDDM_from_template(dm, - positions->size(), - 0, - 0, - face_indices->size(), - face_counts->size()); + new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh, + positions->size(), + 0, + 0, + face_indices->size(), + face_counts->size()); settings.read_flag |= MOD_MESHSEQ_READ_ALL; } @@ -1104,8 +1107,8 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm, /* If the face count changed (e.g. by triangulation), only read points. * This prevents crash from T49813. * TODO(kevin): perhaps find a better way to do this? */ - if (face_counts->size() != dm->getNumPolys(dm) || - face_indices->size() != dm->getNumLoops(dm)) + if (face_counts->size() != existing_mesh->totpoly || + face_indices->size() != existing_mesh->totloop) { settings.read_flag = MOD_MESHSEQ_READ_VERT; @@ -1116,40 +1119,39 @@ DerivedMesh *AbcMeshReader::read_derivedmesh(DerivedMesh *dm, } } - CDStreamConfig config = get_config(new_dm ? new_dm : dm); + CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh); config.time = sample_sel.getRequestedTime(); bool do_normals = false; read_mesh_sample(m_iobject.getFullName(), &settings, m_schema, sample_sel, config, do_normals); - if (new_dm) { + if (new_mesh) { /* Check if we had ME_SMOOTH flag set to restore it. */ - if (!do_normals && check_smooth_poly_flag(dm)) { - set_smooth_poly_flag(new_dm); + if (!do_normals && check_smooth_poly_flag(existing_mesh)) { + set_smooth_poly_flag(new_mesh); } - CDDM_calc_normals(new_dm); - CDDM_calc_edges(new_dm); + BKE_mesh_calc_normals(new_mesh); + BKE_mesh_calc_edges(new_mesh, false, false); /* Here we assume that the number of materials doesn't change, i.e. that * the material slots that were created when the object was loaded from * Alembic are still valid now. */ - size_t num_polys = new_dm->getNumPolys(new_dm); + size_t num_polys = new_mesh->totpoly; if (num_polys > 0) { - MPoly *dmpolies = new_dm->getPolyArray(new_dm); std::map<std::string, int> mat_map; - assign_facesets_to_mpoly(sample_sel, 0, dmpolies, num_polys, mat_map); + assign_facesets_to_mpoly(sample_sel, 0, new_mesh->mpoly, num_polys, mat_map); } - return new_dm; + return new_mesh; } if (do_normals) { - CDDM_calc_normals(dm); + BKE_mesh_calc_normals(existing_mesh); } - return dm; + return existing_mesh; } void AbcMeshReader::assign_facesets_to_mpoly( @@ -1311,16 +1313,22 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str()); m_object->data = mesh; - DerivedMesh *dm = CDDM_from_mesh(mesh); - DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, MOD_MESHSEQ_READ_ALL, NULL); + Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL); + BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true); - if (ndm != dm) { - dm->release(dm); + ISubDSchema::Sample sample; + try { + sample = m_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return; } - DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true); - - const ISubDSchema::Sample sample = m_schema.getValue(sample_sel); Int32ArraySamplePtr indices = sample.getCreaseIndices(); Alembic::Abc::FloatArraySamplePtr sharpnesses = sample.getCreaseSharpnesses(); @@ -1350,29 +1358,41 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec } } -DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm, - const ISampleSelector &sample_sel, - int read_flag, - const char **err_str) +Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh, + const ISampleSelector &sample_sel, + int read_flag, + const char **err_str) { - const ISubDSchema::Sample sample = m_schema.getValue(sample_sel); + ISubDSchema::Sample sample; + try { + sample = m_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + *err_str = "Error reading mesh sample; more detail on the console"; + printf("Alembic: error reading mesh sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return existing_mesh; + } const P3fArraySamplePtr &positions = sample.getPositions(); const Alembic::Abc::Int32ArraySamplePtr &face_indices = sample.getFaceIndices(); const Alembic::Abc::Int32ArraySamplePtr &face_counts = sample.getFaceCounts(); - DerivedMesh *new_dm = NULL; + Mesh *new_mesh = NULL; ImportSettings settings; settings.read_flag |= read_flag; - if (dm->getNumVerts(dm) != positions->size()) { - new_dm = CDDM_from_template(dm, - positions->size(), - 0, - 0, - face_indices->size(), - face_counts->size()); + if (existing_mesh->totvert != positions->size()) { + new_mesh = BKE_mesh_new_nomain_from_template(existing_mesh, + positions->size(), + 0, + 0, + face_indices->size(), + face_counts->size()); settings.read_flag |= MOD_MESHSEQ_READ_ALL; } @@ -1380,8 +1400,8 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm, /* If the face count changed (e.g. by triangulation), only read points. * This prevents crash from T49813. * TODO(kevin): perhaps find a better way to do this? */ - if (face_counts->size() != dm->getNumPolys(dm) || - face_indices->size() != dm->getNumLoops(dm)) + if (face_counts->size() != existing_mesh->totpoly || + face_indices->size() != existing_mesh->totpoly) { settings.read_flag = MOD_MESHSEQ_READ_VERT; @@ -1393,22 +1413,22 @@ DerivedMesh *AbcSubDReader::read_derivedmesh(DerivedMesh *dm, } /* Only read point data when streaming meshes, unless we need to create new ones. */ - CDStreamConfig config = get_config(new_dm ? new_dm : dm); + CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh); config.time = sample_sel.getRequestedTime(); read_subd_sample(m_iobject.getFullName(), &settings, m_schema, sample_sel, config); - if (new_dm) { + if (new_mesh) { /* Check if we had ME_SMOOTH flag set to restore it. */ - if (check_smooth_poly_flag(dm)) { - set_smooth_poly_flag(new_dm); + if (check_smooth_poly_flag(existing_mesh)) { + set_smooth_poly_flag(new_mesh); } - CDDM_calc_normals(new_dm); - CDDM_calc_edges(new_dm); + BKE_mesh_calc_normals(new_mesh); + BKE_mesh_calc_edges(new_mesh, false, false); - return new_dm; + return new_mesh; } - return dm; + return existing_mesh; } diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h index 70d92f894d2..fd6de1001ae 100644 --- a/source/blender/alembic/intern/abc_mesh.h +++ b/source/blender/alembic/intern/abc_mesh.h @@ -26,7 +26,6 @@ #include "abc_customdata.h" #include "abc_object.h" -struct DerivedMesh; struct Mesh; struct ModifierData; @@ -50,8 +49,7 @@ class AbcMeshWriter : public AbcObjectWriter { bool m_is_subd; public: - AbcMeshWriter(Scene *scene, - Object *ob, + AbcMeshWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings); @@ -64,29 +62,28 @@ private: bool isAnimated() const; - void writeMesh(DerivedMesh *dm); - void writeSubD(DerivedMesh *dm); + void writeMesh(struct Mesh *mesh); + void writeSubD(struct Mesh *mesh); - void getMeshInfo(DerivedMesh *dm, std::vector<float> &points, + void getMeshInfo(struct Mesh *mesh, std::vector<float> &points, std::vector<int32_t> &facePoints, std::vector<int32_t> &faceCounts, std::vector<int32_t> &creaseIndices, std::vector<int32_t> &creaseLengths, std::vector<float> &creaseSharpness); - DerivedMesh *getFinalMesh(); - void freeMesh(DerivedMesh *dm); + struct Mesh *getFinalMesh(bool &r_needsfree); - void getMaterialIndices(DerivedMesh *dm, std::vector<int32_t> &indices); + void getMaterialIndices(struct Mesh *mesh, std::vector<int32_t> &indices); - void writeArbGeoParams(DerivedMesh *dm); - void getGeoGroups(DerivedMesh *dm, std::map<std::string, std::vector<int32_t> > &geoGroups); + void writeArbGeoParams(struct Mesh *mesh); + void getGeoGroups(struct Mesh *mesh, std::map<std::string, std::vector<int32_t> > &geoGroups); /* fluid surfaces support */ - void getVelocities(DerivedMesh *dm, std::vector<Imath::V3f> &vels); + void getVelocities(struct Mesh *mesh, std::vector<Imath::V3f> &vels); template <typename Schema> - void writeFaceSets(DerivedMesh *dm, Schema &schema); + void writeFaceSets(struct Mesh *mesh, Schema &schema); }; /* ************************************************************************** */ @@ -105,10 +102,10 @@ public: const char **err_str) const; void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel); - DerivedMesh *read_derivedmesh(DerivedMesh *dm, - const Alembic::Abc::ISampleSelector &sample_sel, - int read_flag, - const char **err_str); + struct Mesh *read_mesh(struct Mesh *existing_mesh, + const Alembic::Abc::ISampleSelector &sample_sel, + int read_flag, + const char **err_str); private: void readFaceSetsSample(Main *bmain, Mesh *mesh, size_t poly_start, @@ -135,10 +132,10 @@ public: const Object *const ob, const char **err_str) const; void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel); - DerivedMesh *read_derivedmesh(DerivedMesh *dm, - const Alembic::Abc::ISampleSelector &sample_sel, - int read_flag, - const char **err_str); + struct Mesh *read_mesh(struct Mesh *existing_mesh, + const Alembic::Abc::ISampleSelector &sample_sel, + int read_flag, + const char **err_str); }; /* ************************************************************************** */ @@ -147,6 +144,6 @@ void read_mverts(MVert *mverts, const Alembic::AbcGeom::P3fArraySamplePtr &positions, const Alembic::AbcGeom::N3fArraySamplePtr &normals); -CDStreamConfig get_config(DerivedMesh *dm); +CDStreamConfig get_config(struct Mesh *mesh); #endif /* __ABC_MESH_H__ */ diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc index 6273507486a..fcb2f5c5ec5 100644 --- a/source/blender/alembic/intern/abc_nurbs.cc +++ b/source/blender/alembic/intern/abc_nurbs.cc @@ -60,12 +60,11 @@ using Alembic::AbcGeom::ONuPatchSchema; /* ************************************************************************** */ -AbcNurbsWriter::AbcNurbsWriter(Scene *scene, - Object *ob, +AbcNurbsWriter::AbcNurbsWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(ob, time_sampling, settings, parent) { m_is_animated = isAnimated(); @@ -131,8 +130,8 @@ void AbcNurbsWriter::do_write() Curve *curve = static_cast<Curve *>(m_object->data); ListBase *nulb; - if (m_object->curve_cache->deformed_nurbs.first != NULL) { - nulb = &m_object->curve_cache->deformed_nurbs; + if (m_object->runtime.curve_cache->deformed_nurbs.first != NULL) { + nulb = &m_object->runtime.curve_cache->deformed_nurbs; } else { nulb = BKE_curve_nurbs_get(curve); @@ -254,7 +253,19 @@ void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele nu->resolv = cu->resolv; const INuPatchSchema &schema = it->first; - const INuPatchSchema::Sample smp = schema.getValue(sample_sel); + INuPatchSchema::Sample smp; + try { + smp = schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + printf("Alembic: error reading nurbs sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return; + } + nu->orderu = smp.getUOrder() - 1; nu->orderv = smp.getVOrder() - 1; diff --git a/source/blender/alembic/intern/abc_nurbs.h b/source/blender/alembic/intern/abc_nurbs.h index abe460a8988..827aa4b365f 100644 --- a/source/blender/alembic/intern/abc_nurbs.h +++ b/source/blender/alembic/intern/abc_nurbs.h @@ -32,8 +32,7 @@ class AbcNurbsWriter : public AbcObjectWriter { bool m_is_animated; public: - AbcNurbsWriter(Scene *scene, - Object *ob, + AbcNurbsWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings); diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc index ddedcf6dcbc..7e0b1ccfbd4 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,14 +58,12 @@ using Alembic::AbcGeom::OStringProperty; /* ************************************************************************** */ -AbcObjectWriter::AbcObjectWriter(Scene *scene, - Object *ob, +AbcObjectWriter::AbcObjectWriter(Object *ob, uint32_t time_sampling, ExportSettings &settings, AbcObjectWriter *parent) : m_object(ob) , m_settings(settings) - , m_scene(scene) , m_time_sampling(time_sampling) , m_first_frame(true) { @@ -247,12 +244,12 @@ Imath::M44d get_matrix(const IXformSchema &schema, const float time) return s0.getMatrix(); } -DerivedMesh *AbcObjectReader::read_derivedmesh(DerivedMesh *dm, - const Alembic::Abc::ISampleSelector &UNUSED(sample_sel), - int UNUSED(read_flag), - const char **UNUSED(err_str)) +struct Mesh *AbcObjectReader::read_mesh(struct Mesh *existing_mesh, + const Alembic::Abc::ISampleSelector &UNUSED(sample_sel), + int UNUSED(read_flag), + const char **UNUSED(err_str)) { - return dm; + return existing_mesh; } void AbcObjectReader::setupObjectTransform(const float time) diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h index 852ef451f23..8794cb61708 100644 --- a/source/blender/alembic/intern/abc_object.h +++ b/source/blender/alembic/intern/abc_object.h @@ -44,7 +44,6 @@ protected: Object *m_object; ExportSettings &m_settings; - Scene *m_scene; uint32_t m_time_sampling; Imath::Box3d m_bounds; @@ -56,8 +55,7 @@ protected: std::string m_name; public: - AbcObjectWriter(Scene *scene, - Object *ob, + AbcObjectWriter(Object *ob, uint32_t time_sampling, ExportSettings &settings, AbcObjectWriter *parent = NULL); @@ -122,7 +120,7 @@ static bool has_animations(Schema &schema, ImportSettings *settings) /* ************************************************************************** */ -struct DerivedMesh; +struct Mesh; using Alembic::AbcCoreAbstract::chrono_t; @@ -178,10 +176,10 @@ public: virtual void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) = 0; - virtual DerivedMesh *read_derivedmesh(DerivedMesh *dm, - const Alembic::Abc::ISampleSelector &sample_sel, - int read_flag, - const char **err_str); + virtual struct Mesh *read_mesh(struct Mesh *mesh, + const Alembic::Abc::ISampleSelector &sample_sel, + int read_flag, + const char **err_str); /** Reads the object matrix and sets up an object transform if animated. */ void setupObjectTransform(const float time); diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc index 738adb4cd3a..c748139a0e6 100644 --- a/source/blender/alembic/intern/abc_points.cc +++ b/source/blender/alembic/intern/abc_points.cc @@ -40,6 +40,8 @@ extern "C" { #include "BKE_scene.h" #include "BLI_math.h" + +#include "DEG_depsgraph_query.h" } using Alembic::AbcGeom::kVertexScope; @@ -58,13 +60,12 @@ using Alembic::AbcGeom::OPointsSchema; /* ************************************************************************** */ -AbcPointsWriter::AbcPointsWriter(Scene *scene, - Object *ob, +AbcPointsWriter::AbcPointsWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings, ParticleSystem *psys) - : AbcObjectWriter(scene, ob, time_sampling, settings, parent) + : AbcObjectWriter(ob, time_sampling, settings, parent) { m_psys = psys; @@ -86,7 +87,8 @@ void AbcPointsWriter::do_write() ParticleKey state; ParticleSimulationData sim; - sim.scene = m_scene; + sim.depsgraph = m_settings.depsgraph; + sim.scene = m_settings.scene; sim.ob = m_object; sim.psys = m_psys; @@ -100,7 +102,7 @@ void AbcPointsWriter::do_write() continue; } - state.time = BKE_scene_frame_get(m_scene); + state.time = DEG_get_ctime(m_settings.depsgraph); if (psys_get_particle_state(&sim, p, &state, 0) == 0) { continue; @@ -171,15 +173,9 @@ bool AbcPointsReader::accepts_object_type(const Alembic::AbcCoreAbstract::Object void AbcPointsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel) { Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str()); + Mesh *read_mesh = this->read_mesh(mesh, sample_sel, 0, NULL); - DerivedMesh *dm = CDDM_from_mesh(mesh); - DerivedMesh *ndm = this->read_derivedmesh(dm, sample_sel, 0, NULL); - - if (ndm != dm) { - dm->release(dm); - } - - DM_to_mesh(ndm, mesh, m_object, CD_MASK_MESH, true); + BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true); if (m_settings->validate_meshes) { BKE_mesh_validate(mesh, false, false); @@ -216,23 +212,35 @@ void read_points_sample(const IPointsSchema &schema, read_mverts(config.mvert, positions, vnormals); } -DerivedMesh *AbcPointsReader::read_derivedmesh(DerivedMesh *dm, - const ISampleSelector &sample_sel, - int /*read_flag*/, - const char ** /*err_str*/) +struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh, + const ISampleSelector &sample_sel, + int /*read_flag*/, + const char **err_str) { - const IPointsSchema::Sample sample = m_schema.getValue(sample_sel); + IPointsSchema::Sample sample; + try { + sample = m_schema.getValue(sample_sel); + } + catch(Alembic::Util::Exception &ex) { + *err_str = "Error reading points sample; more detail on the console"; + printf("Alembic: error reading points sample for '%s/%s' at time %f: %s\n", + m_iobject.getFullName().c_str(), + m_schema.getName().c_str(), + sample_sel.getRequestedTime(), + ex.what()); + return existing_mesh; + } const P3fArraySamplePtr &positions = sample.getPositions(); - DerivedMesh *new_dm = NULL; + Mesh *new_mesh = NULL; - if (dm->getNumVerts(dm) != positions->size()) { - new_dm = CDDM_new(positions->size(), 0, 0, 0, 0); + if (existing_mesh->totvert != positions->size()) { + new_mesh = BKE_mesh_new_nomain(positions->size(), 0, 0, 0, 0); } - CDStreamConfig config = get_config(new_dm ? new_dm : dm); + CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh); read_points_sample(m_schema, sample_sel, config); - return new_dm ? new_dm : dm; + return new_mesh ? new_mesh : existing_mesh; } diff --git a/source/blender/alembic/intern/abc_points.h b/source/blender/alembic/intern/abc_points.h index 369a802d763..e986f9448f4 100644 --- a/source/blender/alembic/intern/abc_points.h +++ b/source/blender/alembic/intern/abc_points.h @@ -38,8 +38,7 @@ class AbcPointsWriter : public AbcObjectWriter { ParticleSystem *m_psys; public: - AbcPointsWriter(Scene *scene, - Object *ob, + AbcPointsWriter(Object *ob, AbcTransformWriter *parent, uint32_t time_sampling, ExportSettings &settings, @@ -64,10 +63,10 @@ public: void readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel); - DerivedMesh *read_derivedmesh(DerivedMesh *dm, - const Alembic::Abc::ISampleSelector &sample_sel, - int read_flag, - const char **err_str); + struct Mesh *read_mesh(struct Mesh *existing_mesh, + const Alembic::Abc::ISampleSelector &sample_sel, + int read_flag, + const char **err_str); }; void read_points_sample(const Alembic::AbcGeom::IPointsSchema &schema, diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc index 5392387663f..81ebfef3e11 100644 --- a/source/blender/alembic/intern/abc_transform.cc +++ b/source/blender/alembic/intern/abc_transform.cc @@ -32,6 +32,8 @@ extern "C" { #include "BLI_math.h" #include "BKE_object.h" + +#include "DEG_depsgraph_query.h" } using Alembic::AbcGeom::OObject; @@ -62,7 +64,7 @@ AbcTransformWriter::AbcTransformWriter(Object *ob, AbcTransformWriter *parent, unsigned int time_sampling, ExportSettings &settings) - : AbcObjectWriter(NULL, ob, time_sampling, settings, parent) + : AbcObjectWriter(ob, time_sampling, settings, parent) , m_proxy_from(NULL) { m_is_animated = hasAnimation(m_object); @@ -80,29 +82,31 @@ AbcTransformWriter::AbcTransformWriter(Object *ob, void AbcTransformWriter::do_write() { + Object *ob_eval = DEG_get_evaluated_object(m_settings.depsgraph, m_object); + if (m_first_frame) { m_visibility = Alembic::AbcGeom::CreateVisibilityProperty(m_xform, m_xform.getSchema().getTimeSampling()); } - m_visibility.set(!(m_object->restrictflag & OB_RESTRICT_VIEW)); + m_visibility.set(!(ob_eval->restrictflag & OB_RESTRICT_VIEW)); if (!m_first_frame && !m_is_animated) { return; } float yup_mat[4][4]; - create_transform_matrix(m_object, yup_mat, + create_transform_matrix(ob_eval, yup_mat, m_inherits_xform ? ABC_MATRIX_LOCAL : ABC_MATRIX_WORLD, m_proxy_from); /* Only apply rotation to root camera, parenting will propagate it. */ - if (m_object->type == OB_CAMERA && (!m_inherits_xform || !has_parent_camera(m_object))) { + if (ob_eval->type == OB_CAMERA && (!m_inherits_xform || !has_parent_camera(ob_eval))) { float rot_mat[4][4]; axis_angle_to_mat4_single(rot_mat, 'X', -M_PI_2); mul_m4_m4m4(yup_mat, yup_mat, rot_mat); } - if (!m_object->parent || !m_inherits_xform) { + if (!ob_eval->parent || !m_inherits_xform) { /* Only apply scaling to root objects, parenting will propagate it. */ float scale_mat[4][4]; scale_m4_fl(scale_mat, m_settings.global_scale); diff --git a/source/blender/alembic/intern/abc_transform.h b/source/blender/alembic/intern/abc_transform.h index 753a4247e9f..12bf9d38007 100644 --- a/source/blender/alembic/intern/abc_transform.h +++ b/source/blender/alembic/intern/abc_transform.h @@ -37,7 +37,6 @@ class AbcTransformWriter : public AbcObjectWriter { Alembic::Abc::M44d m_matrix; bool m_is_animated; - bool m_visible; bool m_inherits_xform; public: diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc index 24a508e8292..53860ab149d 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]) @@ -152,7 +140,10 @@ void create_swapped_rotation_matrix( rz = -euler[1]; break; default: + ry = 0.0f; + rz = 0.0f; BLI_assert(false); + break; } unit_m3(rot_x_mat); @@ -190,11 +181,11 @@ void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMod unit_m3(dst_rot); unit_m4(dst_scale_mat); - /* We assume there is no sheer component and no homogeneous scaling component. */ - BLI_assert(fabs(src_mat[0][3]) < 2 * FLT_EPSILON); - BLI_assert(fabs(src_mat[1][3]) < 2 * FLT_EPSILON); - BLI_assert(fabs(src_mat[2][3]) < 2 * FLT_EPSILON); - BLI_assert(fabs(src_mat[3][3] - 1.0f) < 2 * FLT_EPSILON); + /* TODO(Sybren): This code assumes there is no sheer component and no + * homogeneous scaling component, which is not always true when writing + * non-hierarchical (e.g. flat) objects (e.g. when parent has non-uniform + * scale and the child rotates). This is currently not taken into account + * when axis-swapping. */ /* Extract translation, rotation, and scale form matrix. */ mat4_to_loc_rot_size(src_trans, src_rot, src_scale, src_mat); diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h index 06eb3f140ca..fae73ec9d11 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 b7c1f98bfb0..e295b85afd2 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,7 +230,7 @@ static void find_iobject(const IObject &object, IObject &ret, } struct ExportJobData { - Scene *scene; + ViewLayer *view_layer; Main *bmain; char filename[1024]; @@ -257,20 +260,25 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo G.is_break = false; + DEG_graph_build_from_view_layer(data->settings.depsgraph, + data->bmain, + data->settings.scene, + data->view_layer); + BKE_scene_graph_update_tagged(data->settings.depsgraph, data->bmain); + try { - Scene *scene = data->scene; - AbcExporter exporter(data->bmain, scene, data->filename, data->settings); + AbcExporter exporter(data->bmain, data->filename, data->settings); + Scene *scene = data->settings.scene; /* for the CFRA macro */ const int orig_frame = CFRA; data->was_canceled = false; - exporter(data->bmain, *data->progress, data->was_canceled); + exporter(*data->progress, data->was_canceled); if (CFRA != orig_frame) { CFRA = orig_frame; - BKE_scene_update_for_newframe(data->bmain->eval_ctx, data->bmain, - scene, scene->lay); + BKE_scene_graph_update_for_newframe(data->settings.depsgraph, data->bmain); } data->export_ok = !data->was_canceled; @@ -308,7 +316,8 @@ bool ABC_export( bool as_background_job) { ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData")); - job->scene = scene; + + job->view_layer = CTX_data_view_layer(C); job->bmain = CTX_data_main(C); job->export_ok = false; BLI_strncpy(job->filename, filepath, 1024); @@ -329,14 +338,26 @@ bool ABC_export( * do bigger refactor and maybe there is a better way which does not involve * hardcore refactoring. */ new (&job->settings) ExportSettings(); - job->settings.scene = job->scene; + job->settings.scene = scene; + job->settings.depsgraph = DEG_graph_new(scene, job->view_layer, DAG_EVAL_RENDER); + + /* 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.view_layer = job->view_layer; + 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 +366,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; @@ -363,7 +389,7 @@ bool ABC_export( if (as_background_job) { wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), - job->scene, + job->settings.scene, "Alembic Export", WM_JOB_PROGRESS, WM_JOB_TYPE_ALEMBIC); @@ -606,6 +632,7 @@ enum { struct ImportJobData { Main *bmain; Scene *scene; + ViewLayer *view_layer; char filename[1024]; ImportSettings settings; @@ -621,6 +648,7 @@ struct ImportJobData { bool import_ok; }; +#if 0 ABC_INLINE bool is_mesh_and_strands(const IObject &object) { bool has_mesh = false; @@ -651,6 +679,7 @@ ABC_INLINE bool is_mesh_and_strands(const IObject &object) return has_mesh && has_curve; } +#endif static void import_startjob(void *user_data, short *stop, short *do_update, float *progress) { @@ -807,20 +836,28 @@ static void import_endjob(void *user_data) else { /* Add object to scene. */ Base *base; + LayerCollection *lc; + ViewLayer *view_layer = data->view_layer; + + BKE_view_layer_base_deselect_all(view_layer); - BKE_scene_base_deselect_all(data->scene); + lc = BKE_layer_collection_get_active(view_layer); 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->bmain, lc->collection, ob); + + base = BKE_view_layer_base_find(view_layer, ob); + BKE_view_layer_base_select(view_layer, base); - DAG_id_tag_update_ex(data->bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DEG_id_tag_update(&lc->collection->id, DEG_TAG_COPY_ON_WRITE); + DEG_id_tag_update_ex(data->bmain, &ob->id, + OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | DEG_TAG_BASE_FLAGS_UPDATE); } - DAG_relations_tag_update(data->bmain); + DEG_id_tag_update(&data->scene->id, DEG_TAG_BASE_FLAGS_UPDATE); + DEG_relations_tag_update(data->bmain); } for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { @@ -863,6 +900,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->view_layer = CTX_data_view_layer(C); job->import_ok = false; BLI_strncpy(job->filename, filepath, 1024); @@ -924,12 +962,12 @@ void ABC_get_transform(CacheReader *reader, float r_mat[4][4], float time, float /* ************************************************************************** */ -DerivedMesh *ABC_read_mesh(CacheReader *reader, - Object *ob, - DerivedMesh *dm, - const float time, - const char **err_str, - int read_flag) +Mesh *ABC_read_mesh(CacheReader *reader, + Object *ob, + Mesh *existing_mesh, + const float time, + const char **err_str, + int read_flag) { AbcObjectReader *abc_reader = reinterpret_cast<AbcObjectReader *>(reader); IObject iobject = abc_reader->iobject(); @@ -948,7 +986,7 @@ DerivedMesh *ABC_read_mesh(CacheReader *reader, /* kFloorIndex is used to be compatible with non-interpolating * properties; they use the floor. */ ISampleSelector sample_sel(time, ISampleSelector::kFloorIndex); - return abc_reader->read_derivedmesh(dm, sample_sel, read_flag, err_str); + return abc_reader->read_mesh(existing_mesh, sample_sel, read_flag, err_str); } /* ************************************************************************** */ |