From 11c2a6754bd54085c4fa4be9ea66e006f4079c69 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 30 Nov 2007 13:28:33 +0000 Subject: [PATCH] Bugfix: Random particle distribution did not normalize weights properly, could give particles on invalid faces. --- source/blender/blenkernel/intern/particle_system.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index bee1250a173..6138c651a46 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -494,7 +494,7 @@ static void distribute_particles_on_dm(DerivedMesh *finaldm, Object *ob, Particl //int *vertpart=0; int jitlevel= 1, intersect, distr; float *weight=0,*sum=0,*jitoff=0; - float cur, maxweight=0.0,tweight; + float cur, maxweight=0.0, tweight, totweight; float *v1, *v2, *v3, *v4, co[3], nor[3], co1[3], co2[3], nor1[3]; float cur_d, min_d; DerivedMesh *dm= NULL; @@ -756,9 +756,16 @@ static void distribute_particles_on_dm(DerivedMesh *finaldm, Object *ob, Particl } /* 3. */ + totweight= 0.0f; + for(i=0;i 0.0f) + totweight= 1.0f/totweight; + sum[0]= 0.0f; for(i=0;iflag&PART_TRAND){ float pos; @@ -766,6 +773,7 @@ static void distribute_particles_on_dm(DerivedMesh *finaldm, Object *ob, Particl for(p=0; p