diff options
author | makowalski <makowalski@nvidia.com> | 2021-03-09 20:59:38 +0300 |
---|---|---|
committer | makowalski <makowalski@nvidia.com> | 2021-03-09 20:59:38 +0300 |
commit | c77832df3bdbf399583c10e1d3b47a17c491cd76 (patch) | |
tree | 5f9a865d01daf5074fbfdd1f0dcf025a64288ddd /source | |
parent | 6da1424da40f87e967aa9c93d8e8dfa2d084f148 (diff) |
USD Import: crash on reading no polys.
Fixed a crash where polys were not being read for new meshes when
the MOD_MESHSEQ_READ_POLY flag isn't set. Crash occurs because
downstream code expects polys to exist. Modified the logic to
always read verts and polys for new meshes, regardless of the
value of the read flag.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_mesh.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index db7af371d9c..3b4730acc2f 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -503,6 +503,7 @@ void USDMeshReader::read_attributes(Mesh *mesh, void *cdata = CustomData_get_layer_named(cd, cd_type, name); if (!cdata) { + printf("attr name %s\n", name); cdata = CustomData_add_layer_named(cd, cd_type, CD_DEFAULT, NULL, num, name); } memcpy(cdata, data, num * type_size); @@ -666,7 +667,11 @@ void USDMeshReader::read_mesh_sample(const std::string &iobject_full_name, read_uvs_params(config, abc_mesh_data, schema.getUVsParam(), selector); }*/ - if ((settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0) { + // Note that for new meshes we always want to read verts and polys, + // regradless of the value of the read_flag, to avoid a crash downstream + // in code that expect this data to be there. + + if (new_mesh || (settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0) { for (int i = 0; i < m_positions.size(); i++) { MVert &mvert = mesh->mvert[i]; mvert.co[0] = m_positions[i][0]; @@ -675,7 +680,7 @@ void USDMeshReader::read_mesh_sample(const std::string &iobject_full_name, } } - if ((settings->read_flag & MOD_MESHSEQ_READ_POLY) != 0) { + if (new_mesh || (settings->read_flag & MOD_MESHSEQ_READ_POLY) != 0) { read_mpolys(mesh, mesh_prim, motionSampleTime); if (m_normalInterpolation == pxr::UsdGeomTokens->faceVarying) { process_normals_face_varying(mesh); |