[#18277] Segfault crash by editing mesh with subsurf+ParticleInstance modifiers
[blender.git] / source / blender / blenkernel / intern / modifier.c
index 6bdd395a2ac1f22d1c737b6d7bb20f8fdcb00f5d..566a139f72c406f8f7dd61c337f640ad67a6e61c 100644 (file)
@@ -6380,20 +6380,11 @@ static DerivedMesh * particleInstanceModifier_applyModifier(
        psys->lattice=psys_get_lattice(ob, psys);
 
        if(psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED)){
-               float co[3];
-               for(i=0; i< totvert; i++){
-                       dm->getVertCo(dm,i,co);
-                       if(i==0){
-                               min_co=max_co=co[track];
-                       }
-                       else{
-                               if(co[track]<min_co)
-                                       min_co=co[track];
 
-                               if(co[track]>max_co)
-                                       max_co=co[track];
-                       }
-               }
+               float min_r[3], max_r[3];
+               dm->getMinMax(dm, min_r, max_r);                
+               min_co=min_r[track];
+               max_co=max_r[track];
        }
 
        result = CDDM_from_template(dm, maxvert,dm->getNumEdges(dm)*totpart,maxface);