10-05-2019, 11:05 AM
(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.