Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-09-21 11:46:35 +0300
committerJacques Lucke <jacques@blender.org>2020-09-21 11:46:35 +0300
commitb8b60e132d0382bb360855e52f2f7c522625ca98 (patch)
treef18592cbecc5ca47822d12a5ffd148f2e29cd720 /source/blender/blenkernel/intern/pointcache.c
parent3bb53b0ee640e744219e2a38207d1fbc76ca2068 (diff)
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
Diffstat (limited to 'source/blender/blenkernel/intern/pointcache.c')
-rw-r--r--source/blender/blenkernel/intern/pointcache.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 1263169a3a0..75b88ae7845 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -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;