Fix for bug #11114: boids physics went wrong when the distance between
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 12 May 2008 17:30:32 +0000 (17:30 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 12 May 2008 17:30:32 +0000 (17:30 +0000)
particles was exactly 0.0, for example with emission from verts.

source/blender/blenkernel/intern/particle_system.c

index 596c381b8964cdad9b3510ebcc18563af68ec74e..5112fb08fe637d7935ad179b0ca5502b4a63d284 100644 (file)
@@ -3770,10 +3770,12 @@ static void boid_brain(BoidVecFunc *bvf, ParticleData *pa, Object *ob, ParticleS
                                near=0;
                                for(n=1; n<neighbours; n++){
                                        if(ptn[n].dist<2.0f*pa->size){
-                                               bvf->Subf(dvec,pa->state.co,pars[ptn[n].index].state.co);
-                                               bvf->Mulf(dvec,(2.0f*pa->size-ptn[n].dist)/ptn[n].dist);
-                                               bvf->Addf(avoid,avoid,dvec);
-                                               near++;
+                                               if(ptn[n].dist!=0.0f) {
+                                                       bvf->Subf(dvec,pa->state.co,pars[ptn[n].index].state.co);
+                                                       bvf->Mulf(dvec,(2.0f*pa->size-ptn[n].dist)/ptn[n].dist);
+                                                       bvf->Addf(avoid,avoid,dvec);
+                                                       near++;
+                                               }
                                        }
                                        /* ptn[] is distance ordered so no need to check others */
                                        else break;