@@ -234,18 +234,20 @@ float PEmitter::EstimateImpulse(bool burst) {
234234 if (emission->PushesEmitter ()) {
235235 // Todo... we're not checking emission start/stop times here, so this will always calculate the impulse as if the emission was active.
236236 // There's not really an easy way to do this, since the emission rate is not necessarily constant over time.
237- float emissions = (emission->GetRate () / 60 .0f ) * g_TimerMan.GetDeltaTimeSecs ();
237+ float emissionsPerFrame = (emission->GetRate () / 60 .0f ) * g_TimerMan.GetDeltaTimeSecs ();
238238 float scale = 1 .0F ;
239+
240+ // Get all the particles emitted this frame
241+ emissionsPerFrame *= emission->GetParticleCount ();
242+
243+ // When bursting, add on all the bursted emissions
244+ // We also use m_BurstScale on ALL emissions, not just the extra bursted ones
245+ // This is a bit funky but consistent with the code that applies the impulse
239246 if (burst) {
240- emissions * = emission->GetBurstSize ();
247+ emissionsPerFrame + = emission->GetBurstSize ();
241248 scale = m_BurstScale;
242249 }
243250
244- if (emissions > 0 ) {
245- int extraEmissions = emission->GetParticleCount () - 1 ;
246- emissions += extraEmissions;
247- }
248-
249251 float velMin = emission->GetMinVelocity () * scale;
250252 float velRange = (emission->GetMaxVelocity () - emission->GetMinVelocity ()) * scale * 0 .5f ;
251253 float spread = (std::max (static_cast <float >(c_PI) - (emission->GetSpread () * scale), 0 .0F ) / c_PI); // A large spread will cause the forces to cancel eachother out
@@ -320,7 +322,7 @@ void PEmitter::Update() {
320322 else
321323 m_BurstTriggered = false ;
322324
323- int emissions = 0 ;
325+ int emissionCountTotal = 0 ;
324326 float velMin, velRange, spread;
325327 double currentPPM, SPE;
326328 MovableObject* pParticle = 0 ;
@@ -331,7 +333,7 @@ void PEmitter::Update() {
331333 if (emission->IsEmissionTime ()) {
332334 // Apply the throttle factor to the emission rate
333335 currentPPM = emission->GetRate () * throttleFactor;
334- emissions = 0 ;
336+ int emissionCount = 0 ;
335337
336338 // Only do all this if the PPM is acutally above zero
337339 if (currentPPM > 0 ) {
@@ -342,25 +344,32 @@ void PEmitter::Update() {
342344 emission->m_Accumulator += m_LastEmitTmr.GetElapsedSimTimeS ();
343345
344346 // Now figure how many full emissions can fit in the current accumulator
345- emissions = std::floor (emission->m_Accumulator / SPE);
347+ emissionCount = std::floor (emission->m_Accumulator / SPE);
346348 // Deduct the about to be emitted emissions from the accumulator
347349 emission->m_Accumulator -= emissions * SPE;
348350
349351 RTEAssert (emission->m_Accumulator >= 0 , " Emission accumulator negative!" );
350352 }
351353
354+ float scale = 1 .0F ;
352355 // Add extra emissions if bursting.
353- if (m_BurstTriggered)
354- emissions += emission->GetBurstSize () * std::floor (throttleFactor);
356+ if (m_BurstTriggered) {
357+ emissionCount += emission->GetBurstSize ();
358+ scale = m_BurstScale;
359+ }
360+
361+ // We don't consider extra particles for our emission count, so add prior to multiply
362+ emissionCountTotal += emissionCount;
363+ emissionCount *= emission->GetParticleCount ();
355364
356365 pParticle = 0 ;
357366 emitVel.Reset ();
358367 parentVel = pRootParent->GetVel () * emission->InheritsVelocity ();
359368
360- for (int i = 0 ; i < emissions ; ++i) {
361- velMin = emission->GetMinVelocity () * (m_BurstTriggered ? m_BurstScale : 1.0 ) ;
362- velRange = emission->GetMaxVelocity () - emission->GetMinVelocity () * (m_BurstTriggered ? m_BurstScale : 1.0 ) ;
363- spread = emission->GetSpread () * (m_BurstTriggered ? m_BurstScale : 1.0 ) ;
369+ for (int i = 0 ; i < emissionCount ; ++i) {
370+ velMin = emission->GetMinVelocity () * scale ;
371+ velRange = emission->GetMaxVelocity () - emission->GetMinVelocity () * scale ;
372+ spread = emission->GetSpread () * scale ;
364373 // Make a copy after the reference particle
365374 pParticle = dynamic_cast <MovableObject*>(emission->GetEmissionParticlePreset ()->Clone ());
366375 // Set up its position and velocity according to the parameters of this.
@@ -405,7 +414,7 @@ void PEmitter::Update() {
405414 m_LastEmitTmr.Reset ();
406415
407416 // Count the total emissions since enabling, and stop emitting if beyong limit (and limit is also enabled)
408- m_EmitCount += emissions ;
417+ m_EmitCount += emissionCountTotal ;
409418 if (m_EmitCountLimit > 0 && m_EmitCount > m_EmitCountLimit)
410419 EnableEmission (false );
411420
0 commit comments