[Bf-blender-cvs] [77d11a5] master: Fix T40052, Grid Particles Crash due to invalid empty mesh verts access for bbox calculation.

Lukas Tönne noreply at git.blender.org
Wed May 7 08:04:42 CEST 2014


Commit: 77d11a52b30f9eecbf2080e353ce59fa4db7e0e7
Author: Lukas Tönne
Date:   Wed May 7 07:56:47 2014 +0200
https://developer.blender.org/rB77d11a52b30f9eecbf2080e353ce59fa4db7e0e7

Fix T40052, Grid Particles Crash due to invalid empty mesh verts access
for bbox calculation.

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

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

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

diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 0d45489..d213a88 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -489,15 +489,19 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
 	int totvert=dm->getNumVerts(dm), from=psys->part->from;
 	int i, j, k, p, res=psys->part->grid_res, size[3], axis;
 
-	mv=mvert;
-
 	/* find bounding box of dm */
-	copy_v3_v3(min, mv->co);
-	copy_v3_v3(max, mv->co);
-	mv++;
-
-	for (i=1; i<totvert; i++, mv++) {
-		minmax_v3v3_v3(min, max, mv->co);
+	if (totvert > 0) {
+		mv=mvert;
+		copy_v3_v3(min, mv->co);
+		copy_v3_v3(max, mv->co);
+		mv++;
+		for (i = 1; i < totvert; i++, mv++) {
+			minmax_v3v3_v3(min, max, mv->co);
+		}
+	}
+	else {
+		zero_v3(min);
+		zero_v3(max);
 	}
 
 	sub_v3_v3v3(delta, max, min);




More information about the Bf-blender-cvs mailing list