Commit: c1d1c1dc6b9b1e3d01ea9b8acacd235c1a357500
Author: Bastien Montagne
Date:   Fri Apr 8 16:26:42 2016 +0200
Branches: master
https://developer.blender.org/rBc1d1c1dc6b9b1e3d01ea9b8acacd235c1a357500

Fix T48088: Reproducible crash: Edges + Array Mod + Hair Particles.

Code did not consider the possibility to have no face at all! :P

===================================================================

M       source/blender/blenkernel/intern/particle.c

===================================================================

diff --git a/source/blender/blenkernel/intern/particle.c 
b/source/blender/blenkernel/intern/particle.c
index 0b88533..0987004 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);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to