diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-12-21 17:59:13 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-12-21 18:14:19 +0300 |
commit | bf168a05cd388c02359e52e4ae674c89f13c96a6 (patch) | |
tree | 60a38b4e66e95f83e9d1a0c85691ad3e0fbec4a0 /source/blender/draw/engines/workbench | |
parent | a2a2fe1f22e2cc64a35e05ba605ac4d6e2360303 (diff) |
Workbench: Fix crash when using more than one metaball
Was caused by recent change in logic
Diffstat (limited to 'source/blender/draw/engines/workbench')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_deferred.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 52caeb6cbf4..2096d31659d 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -828,12 +828,14 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) /* Draw textured */ struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob); for (int i = 0; i < materials_len; i++) { - Material *mat = give_current_material(ob, i + 1); - Image *image; - ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL); - int color_type = workbench_material_determine_color_type(wpd, image, ob); - material = get_or_create_material_data(vedata, ob, mat, image, color_type); - DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob); + if (geom_array != NULL && geom_array[i] != NULL) { + Material *mat = give_current_material(ob, i + 1); + Image *image; + ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL); + int color_type = workbench_material_determine_color_type(wpd, image, ob); + material = get_or_create_material_data(vedata, ob, mat, image, color_type); + DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob); + } } } else if (ELEM(wpd->shading.color_type, @@ -845,7 +847,9 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) } else { struct GPUBatch *geom = DRW_cache_object_surface_get(ob); - DRW_shgroup_call_object_add(material->shgrp, geom, ob); + if (geom) { + DRW_shgroup_call_object_add(material->shgrp, geom, ob); + } } } else { @@ -863,9 +867,11 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) geoms = DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len, NULL, NULL, NULL); for (int i = 0; i < materials_len; ++i) { - Material *mat = give_current_material(ob, i + 1); - material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR); - DRW_shgroup_call_object_add(material->shgrp, geoms[i], ob); + if (geoms != NULL && geoms[i] != NULL) { + Material *mat = give_current_material(ob, i + 1); + material = get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR); + DRW_shgroup_call_object_add(material->shgrp, geoms[i], ob); + } } } } |