Page MenuHome

Allow particle lifetime to 0.0 to effectively allow "no emission" in particles
Needs RevisionPublic

Authored by Juan Gea (juang3d) on Aug 18 2020, 7:19 PM.



Right now there is no way to stop emission of a particle system without affecting particle emission rate per second and other things.

The only possible way is to use textures affecting emission density, but it't not stable as textures are not always sampled and if you use the particle system inside a link it's not working at all.

Allowing lifetime to be 0 we are effectively disabling emission without affecting the general aspect of the particle system.

It's a small patch that should not affect any other thing and should be stable.

I made it against the LTS branch, Blender-v2.83-release patch, with the expectation of this to be applied to 2.83 LTS.

AFAIK there is no other way to make this effect, collisions wont' work asn as I said textures are not stable and this will solve the problem of stop emitting without affecting the particle system in general.

Diff Detail

rB Blender

Event Timeline

Juan Gea (juang3d) requested review of this revision.Aug 18 2020, 7:19 PM
Juan Gea (juang3d) created this revision.

I may have done the patch the wrong way, I mean, the green part should be 0.0 and the red part the 1.0, my fault with git diff, I will update this.

Juan Gea (juang3d) edited the summary of this revision. (Show Details)

Diff fixed

@Jeroen Bakker (jbakker) if you can please change the branch to 2.83, I configured master because I imagine I cannot define this for 2.83

We don't commit fixes to 2.83 directly, commits go to master and then the decision can be made to backport it to 2.83.

Ok, no problem, this is fully compatible with master, I just did it with 2.83 to be sure, but this has not changed at all in 2.91 :)

Jacques Lucke (JacquesLucke) requested changes to this revision.Aug 19 2020, 6:41 PM

Unfortunately, it is not that easy. I found at least 5 places where we divide by the lifetime (see P1594).

In a debug build and in a very simple setup, I found one case where we actually divide by zero at runtime (which triggers a runtime error: division by zero from ASAN).

diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 7bfc0ca764f..4e6c2b5eae9 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2307,7 +2307,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa
   // copy_v3_v3(pa->state.ave, states->ave);
   /* finally we do guides */
-  time = (cfra - pa->time) / pa->lifetime;
+  time = (cfra - pa->time) / pa->lifetime; /* Fix this. */
   CLAMP(time, 0.0f, 1.0f);
   copy_v3_v3(, pa->;

Not sure if it is possible to get zero division errors because of this change in other places. That would have to be checked before this patch is merged.

This revision now requires changes to proceed.Aug 19 2020, 6:41 PM