diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-01-28 18:39:33 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-01-28 18:39:37 +0300 |
commit | 3fd4c88e3a2e9d99d45a0856fcc339e013c0a79a (patch) | |
tree | c9349a1f1fc7e80b113ce4110891e27992c12e98 /source/blender/draw/intern/draw_cache.c | |
parent | fd0bc7e002ced8ffd85e9aa3edcae173dbd13392 (diff) |
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
Diffstat (limited to 'source/blender/draw/intern/draw_cache.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 19 |
1 files changed, 19 insertions, 0 deletions
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, |