Fix T59272: dead particles not included in render, but visible in viewport

The issue was that the pointcache was not storing dead particles,
even though they are displayed. This lead to the rendering issue,
because only alive particles can be read from the point cache in
the frame that is rendered.

This also fixes an issue unrelated to rendering: when dead particles
are displayed, their position is incorrect when some frames are
skipped during playback.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D8907
This commit is contained in:
Jacques Lucke 2020-09-21 10:46:35 +02:00
parent 3bb53b0ee6
commit b8b60e132d
Notes: blender-bot 2023-02-14 07:45:38 +01:00
Referenced by issue #59272, Dead particles not included in render (F12), but visible in viewport
1 changed files with 24 additions and 5 deletions

View File

@ -295,9 +295,20 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra
float times[3];
int step = psys->pointcache->step;
/* No need to store unborn or died particles outside cache step bounds */
if (data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step)) {
return 0;
/* Skip some particles that are not stored in the cache. */
if (data[BPHYS_DATA_INDEX]) {
if (psys->part->flag & PART_DIED) {
/* Dead particles are stored when they are displayed. */
if (cfra < pa->time - step) {
return 0;
}
}
else {
/* Particles are only stored in their lifetime. */
if (cfra < pa->time - step || cfra > pa->dietime + step) {
return 0;
}
}
}
times[0] = pa->time;
@ -485,8 +496,16 @@ static int ptcache_particle_totwrite(void *psys_v, int cfra)
return psys->totpart;
}
for (p = 0; p < psys->totpart; p++, pa++) {
totwrite += (cfra >= pa->time - step && cfra <= pa->dietime + step);
if (psys->part->flag & PART_DIED) {
/* Also store dead particles when they are displayed. */
for (p = 0; p < psys->totpart; p++, pa++) {
totwrite += (cfra >= pa->time - step);
}
}
else {
for (p = 0; p < psys->totpart; p++, pa++) {
totwrite += (cfra >= pa->time - step && cfra <= pa->dietime + step);
}
}
return totwrite;