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.
This commit is contained in:
Bastien Montagne 2016-04-09 18:59:05 +02:00
parent d09a372acb
commit 950acb0ced
Notes: blender-bot 2023-02-14 08:02:00 +01:00
Referenced by issue #48307, Child Hairs In Wrong Places
Referenced by issue #47983, Particles - Emit from Verts emits double on one vert
1 changed files with 10 additions and 1 deletions

View File

@ -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) {