From d260cacc9d9c39c9aaa4bed251bbcdddba252065 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 17 Mar 2023 17:07:44 -0400 Subject: [PATCH] Fix #105577: Python MeshPolygon API allows negative material indices This was lost in the refactor to store material indices in a generic attribute. The attribute API still allows this, but that will be handled separately since it's a more complex task. The existing API that already clamped input values should still do that. --- source/blender/makesrna/intern/rna_mesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 222a2b19ebd..e0c872d671e 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -698,7 +698,7 @@ static void rna_MeshPolygon_material_index_set(PointerRNA *ptr, int value) Mesh *mesh = rna_mesh(ptr); int *material_indices = BKE_mesh_material_indices_for_write(mesh); const int index = rna_MeshPolygon_index_get(ptr); - material_indices[index] = value; + material_indices[index] = max_ii(0, value); } static void rna_MeshPolygon_center_get(PointerRNA *ptr, float *values)