From 64a6a86d57ee0c8810b7738bc42950c336d82952 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 16 Aug 2016 16:15:55 +0200 Subject: Fix two memleaks found by coverity. --- source/blender/alembic/intern/alembic_capi.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/alembic') diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index 0e96ac22e11..f9364d55753 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -585,6 +585,9 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa IArchive *archive = open_archive(data->filename); if (!archive || !archive->valid()) { + if (archive) { + delete archive; + } data->error_code = ABC_ARCHIVE_FAIL; return; } -- cgit v1.2.3 From 294b0756b441ac7a41d861ea6fd1088a8a6fd8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 17 Aug 2016 22:06:05 +0200 Subject: Fix T49081: Alembic sampling times are not taking start frame into account. This resulted in animations always starting at frame 0. --- source/blender/alembic/intern/abc_exporter.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source/blender/alembic') diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc index 127e8853789..f71d78bd60e 100644 --- a/source/blender/alembic/intern/abc_exporter.cc +++ b/source/blender/alembic/intern/abc_exporter.cc @@ -175,7 +175,7 @@ void AbcExporter::getShutterSamples(double step, bool time_relative, /* sample all frame */ if (shutter_open == 0.0 && shutter_close == 1.0) { for (double t = 0; t < 1.0; t += step) { - samples.push_back(t / time_factor); + samples.push_back((t + m_settings.frame_start) / time_factor); } } else { @@ -184,7 +184,7 @@ void AbcExporter::getShutterSamples(double step, bool time_relative, const double time_inc = (shutter_close - shutter_open) / nsamples; for (double t = shutter_open; t <= shutter_close; t += time_inc) { - samples.push_back(t / time_factor); + samples.push_back((t + m_settings.frame_start) / time_factor); } } } @@ -325,16 +325,18 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled) break; } - double f = *begin; - setCurrentFrame(bmain, f); + const double frame = *begin; - if (shape_frames.count(f) != 0) { + /* 'frame' is offset by start frame, so need to cancel the offset. */ + setCurrentFrame(bmain, frame - m_settings.frame_start); + + if (shape_frames.count(frame) != 0) { for (int i = 0, e = m_shapes.size(); i != e; ++i) { m_shapes[i]->write(); } } - if (xform_frames.count(f) == 0) { + if (xform_frames.count(frame) == 0) { continue; } -- cgit v1.2.3 From 8e7bbe66ddc402fccf05defc109e6dced74b567b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 17 Aug 2016 22:20:15 +0200 Subject: Alembic import: fix scene min/max time computation to take objects with transform animations into account. --- source/blender/alembic/intern/abc_camera.cc | 2 +- source/blender/alembic/intern/abc_curves.cc | 2 +- source/blender/alembic/intern/abc_mesh.cc | 6 ++++-- source/blender/alembic/intern/abc_nurbs.cc | 2 +- source/blender/alembic/intern/abc_points.cc | 2 +- source/blender/alembic/intern/abc_transform.cc | 2 +- source/blender/alembic/intern/abc_util.h | 11 ++++++++++- 7 files changed, 19 insertions(+), 8 deletions(-) (limited to 'source/blender/alembic') diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc index 38a6d3d33cf..5c34ec1391f 100644 --- a/source/blender/alembic/intern/abc_camera.cc +++ b/source/blender/alembic/intern/abc_camera.cc @@ -109,7 +109,7 @@ AbcCameraReader::AbcCameraReader(const Alembic::Abc::IObject &object, ImportSett ICamera abc_cam(m_iobject, kWrapExisting); m_schema = abc_cam.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcCameraReader::valid() const diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc index 4e1e4e7e490..2b54741a5c5 100644 --- a/source/blender/alembic/intern/abc_curves.cc +++ b/source/blender/alembic/intern/abc_curves.cc @@ -190,7 +190,7 @@ AbcCurveReader::AbcCurveReader(const Alembic::Abc::IObject &object, ImportSettin ICurves abc_curves(object, kWrapExisting); m_curves_schema = abc_curves.getSchema(); - get_min_max_time(m_curves_schema, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_curves_schema, m_min_time, m_max_time); } bool AbcCurveReader::valid() const diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc index f1c7b6b3aa3..b80b7c0c4c8 100644 --- a/source/blender/alembic/intern/abc_mesh.cc +++ b/source/blender/alembic/intern/abc_mesh.cc @@ -968,7 +968,8 @@ AbcMeshReader::AbcMeshReader(const IObject &object, ImportSettings &settings) IPolyMesh ipoly_mesh(m_iobject, kWrapExisting); m_schema = ipoly_mesh.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcMeshReader::valid() const @@ -1120,7 +1121,8 @@ AbcSubDReader::AbcSubDReader(const IObject &object, ImportSettings &settings) ISubD isubd_mesh(m_iobject, kWrapExisting); m_schema = isubd_mesh.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcSubDReader::valid() const diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc index a3c18ad6301..4f57dfdae9e 100644 --- a/source/blender/alembic/intern/abc_nurbs.cc +++ b/source/blender/alembic/intern/abc_nurbs.cc @@ -201,7 +201,7 @@ AbcNurbsReader::AbcNurbsReader(const IObject &object, ImportSettings &settings) : AbcObjectReader(object, settings) { getNurbsPatches(m_iobject); - get_min_max_time(m_schemas[0].first, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_schemas[0].first, m_min_time, m_max_time); } bool AbcNurbsReader::valid() const diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc index fa5b71ac094..758d4827b8a 100644 --- a/source/blender/alembic/intern/abc_points.cc +++ b/source/blender/alembic/intern/abc_points.cc @@ -141,7 +141,7 @@ AbcPointsReader::AbcPointsReader(const Alembic::Abc::IObject &object, ImportSett { IPoints ipoints(m_iobject, kWrapExisting); m_schema = ipoints.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcPointsReader::valid() const diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc index 3326ae0ed84..7f8984f9970 100644 --- a/source/blender/alembic/intern/abc_transform.cc +++ b/source/blender/alembic/intern/abc_transform.cc @@ -137,7 +137,7 @@ AbcEmptyReader::AbcEmptyReader(const Alembic::Abc::IObject &object, ImportSettin Alembic::AbcGeom::IXform xform(object, Alembic::AbcGeom::kWrapExisting); m_schema = xform.getSchema(); - get_min_max_time(m_schema, m_min_time, m_max_time); + get_min_max_time(m_iobject, m_schema, m_min_time, m_max_time); } bool AbcEmptyReader::valid() const diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h index 688a25d85f6..8cdfe21e43f 100644 --- a/source/blender/alembic/intern/abc_util.h +++ b/source/blender/alembic/intern/abc_util.h @@ -64,7 +64,7 @@ void create_input_transform(const Alembic::AbcGeom::ISampleSelector &sample_sel, float r_mat[4][4], float scale, bool has_alembic_parent = false); template -void get_min_max_time(const Schema &schema, chrono_t &min, chrono_t &max) +void get_min_max_time_ex(const Schema &schema, chrono_t &min, chrono_t &max) { const Alembic::Abc::TimeSamplingPtr &time_samp = schema.getTimeSampling(); @@ -81,6 +81,15 @@ void get_min_max_time(const Schema &schema, chrono_t &min, chrono_t &max) } } +template +void get_min_max_time(const Alembic::AbcGeom::IObject &object, const Schema &schema, chrono_t &min, chrono_t &max) +{ + get_min_max_time_ex(schema, min, max); + + Alembic::AbcGeom::IXform parent(object.getParent(), Alembic::AbcGeom::kWrapExisting); + get_min_max_time_ex(parent.getSchema(), min, max); +} + bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name); /* ************************** */ -- cgit v1.2.3 From 11e9c5e10a9914413af704d714bd1a5991112fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 17 Aug 2016 23:03:34 +0200 Subject: Fix T49104: normal problem in imported Alembic objects Recompute the normals if the normals are supposed to be varying (e.g. in the ISchema). --- source/blender/alembic/intern/alembic_capi.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/alembic') diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index f9364d55753..f42c708b4c2 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -936,12 +936,12 @@ static DerivedMesh *read_mesh_sample(DerivedMesh *dm, const IObject &iobject, co CDStreamConfig config = get_config(new_dm ? new_dm : dm); - bool has_loop_normals = false; - read_mesh_sample(&settings, schema, sample_sel, config, has_loop_normals); + bool do_normals = false; + read_mesh_sample(&settings, schema, sample_sel, config, do_normals); if (new_dm) { /* Check if we had ME_SMOOTH flag set to restore it. */ - if (!has_loop_normals && check_smooth_poly_flag(dm)) { + if (!do_normals && check_smooth_poly_flag(dm)) { set_smooth_poly_flag(new_dm); } @@ -951,6 +951,10 @@ static DerivedMesh *read_mesh_sample(DerivedMesh *dm, const IObject &iobject, co return new_dm; } + if (do_normals) { + CDDM_calc_normals(dm); + } + return dm; } -- cgit v1.2.3 From 5f7611a8f14e177b4d2d2391ebc4725eafdf4073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Fri, 19 Aug 2016 05:22:35 +0200 Subject: Alembic: fix crash accessing invalid objects. --- source/blender/alembic/intern/abc_util.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/alembic') diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h index 8cdfe21e43f..648570f5f27 100644 --- a/source/blender/alembic/intern/abc_util.h +++ b/source/blender/alembic/intern/abc_util.h @@ -86,8 +86,11 @@ void get_min_max_time(const Alembic::AbcGeom::IObject &object, const Schema &sch { get_min_max_time_ex(schema, min, max); - Alembic::AbcGeom::IXform parent(object.getParent(), Alembic::AbcGeom::kWrapExisting); - get_min_max_time_ex(parent.getSchema(), min, max); + const Alembic::AbcGeom::IObject &parent = object.getParent(); + if (parent.valid() && Alembic::AbcGeom::IXform::matches(parent.getMetaData())) { + Alembic::AbcGeom::IXform xform(parent, Alembic::AbcGeom::kWrapExisting); + get_min_max_time_ex(xform.getSchema(), min, max); + } } bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name); -- cgit v1.2.3