-
Notifications
You must be signed in to change notification settings - Fork 0
3. Particle Group Features
Particle groups can be stacked by attaching one group to another.
parentGroup.attachChild(childGroup);
Child groups are able to inherit certain properties from their parents. Such as update speed, decay rate, etc. This is useful for organizing groups together that participating in the same effect.
Having zero capacity is legal, and, in fact, default. Zero capacity is useful for having as the overall parent of a single effect, even though that group cannot actually contain particles.
A group (and child groups) can be delayed from updating by setting the initial delay of the group. While in the group is in delay, neither particles or drivers will be updated.
group.setInitialDelay(1.0f);
The delay value represents the number of seconds of delay time since the group was attached to the scene graph.
A group (and child groups) can be played in slow/fast motion by setting the update speed of the group.
// makes the simulation run twice as fast
group.setUpdateSpeed(2.0f);
Setting the update speed to zero will make the system not visibly update.
Important: Make sure to use the
tpf
argument when writing drivers for this reason.
This parameter makes particles decay slower or faster.
group.setDecayRate(2.0f);
Decay rate is applied after update speed, so an update speed of 2 and a decay rate of 3 would result in particles decaying 6 times faster.
By default, this property is not inherited from parent groups, but that can be enabled if desired.
group.setInheritDecayRate(true);
ParticleGroup has the ability to dynamically resize its capacity to allow for more particles. This feature is disabled by default, but can be enabled by setting the dynamic sizing step to >= 0.
group.setDynamicSizingStep(0);
The value indicates how far above the current size (number of particles, including ones just added) the capacity should be set to. A value of 0 sets the capacity to the current size. A value of 5 sets the capacity to be 5 greater than the current size. For most cases requiring this feature, it is suggested to set the dynamic sizing step to be as high as reasonably possible, since does not require geometries to reload their buffers nearly as much.
Since this feature does force buffers to be reloaded, it is not recommended to use this feature except during certain circumstances.
Note: If dynamic capacity is enabled, overflow strategies will not be used, because the group never really exceeds its capacity.
Particles groups can be reset and used again if desired.
group.reset();
Resetting clears the group of all particles, and it resets the simulation time (getTime()
). Drivers are notified by their groupReset
method, and are expected to completely reset themselves.
A particle group (and child groups) can be paused.
group.pause();
If a group (or a parent group) is paused, the group does not update its particles or drivers, it does not accept new particles, and it does not allow resetting. Subsequent particle geometries do not attempt to update buffers in this state.
This feature can be useful for debugging or overall game pauses, and it is technically a more efficient state, but it is generally better practice to set the update speed to zero instead.