From 3fd4c88e3a2e9d99d45a0856fcc339e013c0a79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 28 Jan 2020 16:39:33 +0100 Subject: Fix T72593 Blender crashes when modifier change the material count Instead of changing the modifiers behavior, we make sure to always use the data->totcol instead of the ob->totcol. Also we centralize getting this number to avoid future issues. Fix T72593 Blender crashes when separating mesh Fix T72017 Crash on set visibility change --- source/blender/draw/intern/draw_cache.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source/blender/draw/intern/draw_cache.c') diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index f2e43e032a9..083901c9ebe 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -824,6 +824,25 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob) } } +int DRW_cache_object_material_count_get(struct Object *ob) +{ + short type = (ob->runtime.mesh_eval != NULL) ? OB_MESH : ob->type; + + switch (type) { + case OB_MESH: + return DRW_mesh_material_count_get(ob->data); + case OB_CURVE: + case OB_SURF: + case OB_FONT: + return DRW_curve_material_count_get(ob->data); + case OB_MBALL: + return DRW_metaball_material_count_get(ob->data); + default: + BLI_assert(0); + return 0; + } +} + GPUBatch **DRW_cache_object_surface_material_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len, -- cgit v1.2.3