Possible fix for [#26190] Changing particle amount crashes
authorJanne Karhu <jhkarh@gmail.com>
Wed, 23 Feb 2011 10:42:27 +0000 (10:42 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Wed, 23 Feb 2011 10:42:27 +0000 (10:42 +0000)
* In some cases fluid particles could be born at the exact same locations. Now these cases are just ignored and such particles don't effect each other.

source/blender/blenkernel/intern/particle_system.c

index c1a6558aea34c0eeb3c386b8ca6574441906d639..fd792168c6bb5af47d9bec54def635163ba904fd 100644 (file)
@@ -2286,6 +2286,10 @@ static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData *
 
        /* pressure and near pressure */
        for(n=own_psys?1:0; n<neighbours; n++) {
+               /* disregard particles at the exact same location */
+               if(ptn[n].dist < FLT_EPSILON)
+                       continue;
+
                sub_v3_v3(ptn[n].co, pa->prev_state.co);
                mul_v3_fl(ptn[n].co, 1.f/ptn[n].dist);
                q = ptn[n].dist/h;
@@ -2305,6 +2309,10 @@ static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData *
 
        /* main calculations */
        for(n=own_psys?1:0; n<neighbours; n++) {
+               /* disregard particles at the exact same location */
+               if(ptn[n].dist < FLT_EPSILON)
+                       continue;
+
                npa = psys->particles + ptn[n].index;
 
                rij = ptn[n].dist;