diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-04-09 19:59:05 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-04-09 19:59:05 +0300 |
commit | 950acb0ced2b35a26222778fcac132a8986bb71b (patch) | |
tree | 3e108bae014133615ad2b7f8f7e0e37c88f858e9 /source/blender/blenkernel/intern/particle_distribute.c | |
parent | d09a372acbfe5a8b93dde60b1ed3b8b2b548c82e (diff) |
Fix T47983, Take II: Particles - Emit from Verts emits double on one vert.
Previous fix made another issue even more visible, leading to +1 particle on first vert
and none on last one. This commit should fix both original and new issues.
Diffstat (limited to 'source/blender/blenkernel/intern/particle_distribute.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle_distribute.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c index ccbc239f0d6..b871e3eb115 100644 --- a/source/blender/blenkernel/intern/particle_distribute.c +++ b/source/blender/blenkernel/intern/particle_distribute.c @@ -1030,7 +1030,16 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti double step, pos; step= (totpart < 2) ? 0.5 : 1.0/(double)totpart; - pos = (from == PART_FROM_VERT) ? 0.0 : 1e-6; /* tiny offset to avoid zero weight face */ + /* This is to address tricky issues with vertex-emitting when user tries (and expects) exact 1-1 vert/part + * distribution (see T47983 and its two example files). It allows us to consider pos as + * 'midpoint between v and v+1' (or 'p and p+1', depending whether we have more vertices than particles or not), + * and avoid stumbling over float imprecisions in element_sum. */ + if (from == PART_FROM_VERT) { + pos = (totpart < totelem) ? 0.5 / (double)totelem : step * 0.5; /* We choose the smaller step. */ + } + else { + pos = 1e-6; /* tiny offset to avoid zero weight face */ + } i= 0; for (p=0; p<totpart; p++, pos+=step) { |