From c1d1c1dc6b9b1e3d01ea9b8acacd235c1a357500 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 8 Apr 2016 16:26:42 +0200 Subject: Fix T48088: Reproducible crash: Edges + Array Mod + Hair Particles. Code did not consider the possibility to have no face at all! :P --- source/blender/blenkernel/intern/particle.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0b8853364d6..098700495a0 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1422,7 +1422,6 @@ int psys_particle_dm_face_lookup( { MFace *mtessface_final; OrigSpaceFace *osface_final; - int totface_final; int pindex_orig; float uv[2], (*faceuv)[2]; @@ -1430,6 +1429,13 @@ int psys_particle_dm_face_lookup( const int *index_mf_to_mpoly = NULL; const int *index_mp_to_orig = NULL; + const int totface_final = dm_final->getNumTessFaces(dm_final); + const int totface_deformed = dm_deformed ? dm_deformed->getNumTessFaces(dm_deformed) : totface_final; + + if (ELEM(0, totface_final, totface_deformed)) { + return DMCACHE_NOTFOUND; + } + index_mf_to_mpoly = dm_final->getTessFaceDataArray(dm_final, CD_ORIGINDEX); index_mp_to_orig = dm_final->getPolyDataArray(dm_final, CD_ORIGINDEX); BLI_assert(index_mf_to_mpoly); @@ -1451,11 +1457,6 @@ int psys_particle_dm_face_lookup( index_mf_to_mpoly_deformed = NULL; - totface_final = dm_final->getNumTessFaces(dm_final); - if (!totface_final) { - return DMCACHE_NOTFOUND; - } - mtessface_final = dm_final->getTessFaceArray(dm_final); osface_final = dm_final->getTessFaceDataArray(dm_final, CD_ORIGSPACE); -- cgit v1.2.3