From 3158fc2593e1afc29280187d9e427a6c21a8f37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 28 Sep 2020 14:12:33 +0200 Subject: [PATCH] Fix T80967: Alembic, crash when the imported sim from Houdini starts Compare mesh loop count with number of loop normals before reading the loop normals. Houdini doesn't always write the correct loop normals to Alembic. When a mesh is animated and then replaced by a fluid simulation, Houdini will still write the original mesh's loop normals, but the mesh verts/loops/polys are from the simulation. In such cases the normals cannot be mapped to the mesh, so it's better to ignore them. --- source/blender/io/alembic/intern/abc_reader_mesh.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc index 5a42be2bb02..ead908e87c2 100644 --- a/source/blender/io/alembic/intern/abc_reader_mesh.cc +++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc @@ -271,10 +271,19 @@ static void process_loop_normals(CDStreamConfig &config, const N3fArraySamplePtr return; } + Mesh *mesh = config.mesh; + if (loop_count != mesh->totloop) { + /* This happens in certain Houdini exports. When a mesh is animated and then replaced by a + * fluid simulation, Houdini will still write the original mesh's loop normals, but the mesh + * verts/loops/polys are from the simulation. In such cases the normals cannot be mapped to the + * mesh, so it's better to ignore them. */ + process_no_normals(config); + return; + } + float(*lnors)[3] = static_cast( MEM_malloc_arrayN(loop_count, sizeof(float[3]), "ABC::FaceNormals")); - Mesh *mesh = config.mesh; MPoly *mpoly = mesh->mpoly; const N3fArraySample &loop_normals = *loop_normals_ptr; int abc_index = 0;