Fix #141477: Crash during material selection
Material selection didn't support empty geometries. Geometry list can have nullptrs, when meshes contain more than 16 materials, but some materials slots are not actually used in the mesh. Material selection used to still looped over all the materials and tried to draw geometry that aren't there. Regression from !139781 Pull Request: https://projects.blender.org/blender/blender/pulls/141608
This commit is contained in:
@@ -280,10 +280,16 @@ class Prepass : Overlay {
|
||||
ResourceHandle res_handle = manager.unique_handle(ob_ref);
|
||||
|
||||
for (int material_id : geom_list.index_range()) {
|
||||
/* Meshes with more than 16 materials can have nullptr in the geometry list as materials are
|
||||
* not filled for unused materials indices. We should actually use `material_indices_used`
|
||||
* but these are only available for meshes. */
|
||||
if (geom_list[material_id] == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
select::ID select_id = use_material_slot_selection_ ?
|
||||
res.select_id(ob_ref, (material_id + 1) << 16) :
|
||||
res.select_id(ob_ref);
|
||||
|
||||
if (res.is_selection() && (pass == mesh_ps_)) {
|
||||
/* Conservative shader needs expanded draw-call. */
|
||||
pass->draw_expand(
|
||||
|
||||
Reference in New Issue
Block a user