diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-01-08 22:46:28 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-01-08 22:46:28 +0300 |
commit | 45bc4e320970f3d7f952fd0d0fa762322d407bd7 (patch) | |
tree | 2032d3e492f337209bcd4f48f8a4f89c21c0942e /source/blender | |
parent | d5e73fa13dd275fb9c76b1e41142ab086dd2e6be (diff) |
Fix T94713: Alembic crash with empty frames and velocities
Some software or processing tools (videogrammetry in this case) may
export malformed files with velocity data even when the frame is empty
for some reason. We need to explicity compare the data size with the
vertex size, and refuse to load the attribute if there is a data size
mismatch.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/io/alembic/intern/abc_reader_mesh.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index adf1a3e241c..83ca3399db5 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -463,13 +463,17 @@ static void read_velocity(const V3fArraySamplePtr &velocities, const CDStreamConfig &config, const float velocity_scale) { + const int num_velocity_vectors = static_cast<int>(velocities->size()); + if (num_velocity_vectors != config.mesh->totvert) { + /* Files containing videogrammetry data may be malformed and export velocity data on missing + * frames (most likely by copying the last valid data). */ + return; + } + CustomDataLayer *velocity_layer = BKE_id_attribute_new( &config.mesh->id, "velocity", CD_PROP_FLOAT3, ATTR_DOMAIN_POINT, nullptr); float(*velocity)[3] = (float(*)[3])velocity_layer->data; - const int num_velocity_vectors = static_cast<int>(velocities->size()); - BLI_assert(num_velocity_vectors == config.mesh->totvert); - for (int i = 0; i < num_velocity_vectors; i++) { const Imath::V3f &vel_in = (*velocities)[i]; copy_zup_from_yup(velocity[i], vel_in.getValue()); |