Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-01-28 18:39:33 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-01-28 18:39:37 +0300
commit3fd4c88e3a2e9d99d45a0856fcc339e013c0a79a (patch)
treec9349a1f1fc7e80b113ce4110891e27992c12e98 /source/blender/draw/intern/draw_cache_impl_metaball.c
parentfd0bc7e002ced8ffd85e9aa3edcae173dbd13392 (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_impl_metaball.c')
-rw-r--r--source/blender/draw/intern/draw_cache_impl_metaball.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c
index e3bfcbde3ef..c14e66c2b47 100644
--- a/source/blender/draw/intern/draw_cache_impl_metaball.c
+++ b/source/blender/draw/intern/draw_cache_impl_metaball.c
@@ -25,6 +25,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_math_base.h"
#include "BLI_utildefines.h"
#include "DNA_meta_types.h"
@@ -206,6 +207,8 @@ GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob,
return NULL;
}
+ BLI_assert(gpumat_array_len == DRW_metaball_material_count_get(mb));
+
MetaBallBatchCache *cache = metaball_batch_cache_get(mb);
if (cache->shaded_triangles == NULL) {
cache->mat_len = gpumat_array_len;
@@ -270,3 +273,8 @@ struct GPUBatch *DRW_metaball_batch_cache_get_edge_detection(struct Object *ob,
return cache->edge_detection;
}
+
+int DRW_metaball_material_count_get(MetaBall *mb)
+{
+ return max_ii(1, mb->totcol);
+}