Fix for bug #11114: boids physics went wrong when the distance between

particles was exactly 0.0, for example with emission from verts.
This commit is contained in:
Brecht Van Lommel 2008-05-12 17:30:32 +00:00
parent d2fcba7f65
commit 916120b98c

@ -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;