Skip to content

Commit

Permalink
Main: ParticleEmitter - new take on burst mode
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Aug 4, 2021
1 parent 9359691 commit 1316cf2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Docs/src/particle-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ format: direction\_position\_reference <x> <y> <z> <enable&

## emission\_rate

Sets how many particles per second should be emitted. The specific emitter does not have to emit these in a continuous burst - this is a relative parameter and the emitter may choose to emit all of the second’s worth of particles every half-second for example, the behaviour depends on the emitter. The emission rate will also be limited by the particle system’s ’quota’ setting.
Sets how many particles per second should be emitted. The specific emitter does not have to emit these in a continuous manner - this is a relative parameter and the emitter may choose to emit all of the second’s worth of particles every half-second for example, the behaviour depends on the emitter. The emission rate will also be limited by the particle system’s ’quota’ setting.

format: emission\_rate &lt;particles\_per\_second&gt;<br> example: emission\_rate 50<br> default: 10<br>

Expand Down Expand Up @@ -355,10 +355,13 @@ format: as time\_to\_live<br> example:<br>     time\_to\_live\_min 2<br>  

## duration

Sets the number of seconds the emitter is active. The emitter can be started again, see [repeat\_delay](#repeat_005fdelay). A value of 0 means infinite duration. See also the duration\_min and duration\_max attributes which let you set a duration range instead of a fixed one.
Sets the number of seconds the emitter is active. The emitter can be started again, see [repeat\_delay](#repeat_005fdelay).
See also the duration\_min and duration\_max attributes which let you set a duration range instead of a fixed one.

format: duration &lt;seconds&gt;<br> example:<br>     duration 2.5<br> default: 0<br> <br>

@note A value of 0 means infinite duration. A value < 0 means "burst" where @c emission_rate of particles are emitted once in the next frame.

<a name="duration_005fmin"></a><a name="duration_005fmax"></a>

## duration\_min & duration\_max
Expand Down
6 changes: 6 additions & 0 deletions OgreMain/src/OgreParticleEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ namespace Ogre
{
if (mEnabled)
{
if(mDurationMax < 0)
{
// single-shot burst
setEnabled(false);
return mEmissionRate;
}
// Keep fractions, otherwise a high frame rate will result in zero emissions!
mRemainder += mEmissionRate * timeElapsed;
unsigned short intRequest = (unsigned short)mRemainder;
Expand Down

0 comments on commit 1316cf2

Please sign in to comment.