[Bf-blender-cvs] [b8b60e132d0] master: Fix T59272: dead particles not included in render, but visible in viewport

Jacques Lucke noreply at git.blender.org
Mon Sep 21 10:46:55 CEST 2020


Commit: b8b60e132d0382bb360855e52f2f7c522625ca98
Author: Jacques Lucke
Date:   Mon Sep 21 10:46:35 2020 +0200
Branches: master
https://developer.blender.org/rBb8b60e132d0382bb360855e52f2f7c522625ca98

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

===================================================================

M	source/blender/blenkernel/intern/pointcache.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list