Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Changing Num Particles in Runtime Stops Emission
#1
Hi,

I'm experimenting with changing the Num Particles field during run time, this causes the Active Particles to be set to 0, and all emission stops and the Editor needs a restart.

Any ideas?

Thanks.
Reply
#2
(10-05-2019, 10:16 AM)Komsur Wrote: Hi,

I'm experimenting with changing the Num Particles field during run time, this causes the Active Particles to be set to 0, and all emission stops and the Editor needs a restart.

Any ideas?

Thanks.

You cannot change the size of the emitter's particle pool at runtime. This is because Obi is designed to preallocate memory when possible, to avoid CG spikes and memory allocation overhead.

Each actor (such as the ObiEmitter) allocates particles from the solver once, when it is initialized. Then it spawns particles from this pool by increasing the amount of ActiveParticles, when a particle dies it is returned to the pool by swapping it with the last active one and decreasing ActiveParticles.

So:
- NumParticles is the maximum amount of particles that can exist in the emitter, its pool size. This should not be changed at runtime, if you do then the emitter will be invalidated and all particles deactivated.

- ActiveParticles is the current amount of emitted particles, between 0 and NumParticles. This changes dynamically at runtime.
Reply
#3
(10-05-2019, 11:05 AM)josemendez Wrote: You cannot change the size of the emitter's particle pool at runtime. This is because Obi is designed to preallocate memory when possible, to avoid CG spikes and memory allocation overhead.

Each actor (such as the ObiEmitter) allocates particles from the solver once, when it is initialized. Then it spawns particles from this pool by increasing the amount of ActiveParticles, when a particle dies it is returned to the pool by swapping it with the last active one and decreasing ActiveParticles.

So:
- NumParticles is the maximum amount of particles that can exist in the emitter, its pool size. This should not be changed at runtime, if you do then the emitter will be invalidated and all particles deactivated.

- ActiveParticles is the current amount of emitted particles, between 0 and NumParticles. This changes dynamically at runtime.
Okay, so, is there a way of forcing the amount of active particles? I see that it's a read-only field, so probably not.
Reply
#4
(13-05-2019, 08:02 AM)Komsur Wrote: Okay, so, is there a way of forcing the amount of active particles? I see that it's a read-only field, so probably not.

Why'd you want to do that? this is entirely managed by the emitter, you should never need to modify the number of active particles directly. Moreover, the amount of particles used to represent a certain volume of fluid is automatically calculated from the resolution and emission speed. The pool size (num particles) is allowed to be set in order to cap the maximum amount of particles that can ever be active, but otherwise thinking in terms of particle count is discouraged. Unlike a regular particle system, the amount of fluid is expressed in volume units, not particle counts.

That being said, you can ensure a certain amount of particles is always active by setting the lifespan to inifinite, then using "Burst" emission mode so that all particles needed to cover the emission shape are emitted at once.
Reply
#5
(13-05-2019, 08:29 AM)josemendez Wrote: Why'd you want to do that? this is entirely managed by the emitter, you should never need to modify the number of active particles directly. Moreover, the amount of particles used to represent a certain volume of fluid is automatically calculated from the resolution and emission speed. The pool size (num particles) is allowed to be set in order to cap the maximum amount of particles that can ever be active, but otherwise thinking in terms of particle count is discouraged. Unlike a regular particle system, the amount of fluid is expressed in volume units, not particle counts.

That being said, you can ensure a certain amount of particles is always active by setting the lifespan to inifinite, then using "Burst" emission mode so that all particles needed to cover the emission shape are emitted at once.


Ideally, I'd like to change the amount of fluid that is spawned based on a flow rate float value we're receiving from another program, as that float value would be dynamically changing and I'd like to avoid making two emitters for the low and high float values.
Reply
#6
(13-05-2019, 02:02 PM)Komsur Wrote: Ideally, I'd like to change the amount of fluid that is spawned based on a flow rate float value we're receiving from another program, as that float value would be dynamically changing and I'd like to avoid making two emitters for the low and high float values.

The emitter's "speed" property controls both the amount of particles emitted per second and their speed, to maintain a constant (or as constant as possible, given the discrete nature of particle-based representations) flow. This is similar to how a real-life faucet works.

You might be able to directly set the emitter's speed to depend on your flow value, depending on what your value represents. I can give more details about how "speed" affects emission, if you need.
Reply
#7
Hi, I have a vial of fluid that I'd like to dynamically fill up / empty using a single particle emitter. I cannot successfully control the total number of active particles from Obi Emitter. I tried setting the "max pool size" as suggested by @josemendez but this had no effect (sliding the slider all the way between 0 and 1). 

I just need to have a total particle count of 100 or so, then arbitrarily decide at runtime to only have 20 or 55 of those particles active. Using DeactivateParticle causes the particle system to fritz out. 

What is the recommended way to set the number of active particles?
Reply