Fix #124009: Clamp material index when uploading mesh through Hydra
Prevent crash from a mesh created around the time of Blender 4.0 with bad (negative) material indices on some faces. The Poly Haven folks were poked to fix the actual asset as well but it's simple enough for us to clamp in this code path, especially since we were already doing it for the upper bound. Pull Request: https://projects.blender.org/blender/blender/pulls/124026
This commit is contained in:
committed by
Jesse Yurkovich
parent
032182f572
commit
f9b2edbf01
@@ -400,7 +400,7 @@ void MeshData::write_submeshes(const Mesh *mesh)
|
||||
IndexMask::from_groups<int>(
|
||||
corner_tris.index_range(),
|
||||
memory,
|
||||
[&](const int i) { return std::min(material_indices[tri_faces[i]], max_index); },
|
||||
[&](const int i) { return std::clamp(material_indices[tri_faces[i]], 0, max_index); },
|
||||
triangles_by_material);
|
||||
|
||||
threading::parallel_for(submeshes_.index_range(), 1, [&](const IndexRange range) {
|
||||
|
||||
Reference in New Issue
Block a user