Fix: Collada import assert with faceless prims

Importing `COLLADAFW::MeshPrimitive::LINES` would assert trying to get
the `material_indices` (these are on the Face Domain -- which does not
exist here).

To resolve, early out if we know we handle LINES.

Probably didnt happen before 45cff837bc

Stumbled over this looking into !120737

Pull Request: https://projects.blender.org/blender/blender/pulls/120738
This commit is contained in:
Philipp Oeser
2024-04-17 14:21:56 +02:00
committed by Philipp Oeser
parent 0bda626ba3
commit 916c4fcdac

View File

@@ -646,6 +646,10 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh,
int collada_meshtype = mp->getPrimitiveType();
if (collada_meshtype == COLLADAFW::MeshPrimitive::LINES) {
continue; /* read the lines later after all the rest is done */
}
/* Since we cannot set `poly->mat_nr` here, we store a portion of `mesh->mpoly` in Primitive.
*/
Primitive prim = {face_index, &material_indices.span[face_index], 0};
@@ -797,10 +801,6 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh,
}
}
else if (collada_meshtype == COLLADAFW::MeshPrimitive::LINES) {
continue; /* read the lines later after all the rest is done */
}
if (mp_has_faces) {
mat_prim_map[mp->getMaterialId()].push_back(prim);
}