diff --git a/src/objects/ParticleObject.cpp b/src/objects/ParticleObject.cpp index 752d326c..cacaf996 100644 --- a/src/objects/ParticleObject.cpp +++ b/src/objects/ParticleObject.cpp @@ -159,7 +159,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe pobj->m_pParticle = NULL; if ( lifeTime != 0 ) - pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + lifeTime; + pobj->m_nRemoveTimer = lifeTime; else pobj->m_nRemoveTimer = 0; @@ -240,7 +240,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe pobj->m_nSkipFrames = 1; pobj->m_nCreationChance = 0; pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.3f); - pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + 5000; + pobj->m_nRemoveTimer = 5000; CAudioHydrant::Add(pobj); break; } @@ -373,7 +373,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe pobj->m_nNumEffectCycles = 1; pobj->m_nSkipFrames = 1; pobj->m_nCreationChance = 0; - pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds(); + pobj->m_nRemoveTimer = 0; break; } @@ -384,7 +384,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe pobj->m_nNumEffectCycles = 1; pobj->m_nSkipFrames = 1; pobj->m_nCreationChance = 0; - pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds(); + pobj->m_nRemoveTimer = 0; pobj->m_vecTarget.Normalise(); break; } @@ -483,7 +483,7 @@ void CParticleObject::UpdateClose(void) } } - if ( ++this->m_nFrameCounter / CTimer::GetTimeStepFix() >= this->m_nSkipFrames ) + if ( ++this->m_nFrameCounter >= this->m_nSkipFrames ) { this->m_nFrameCounter = 0; @@ -1087,7 +1087,7 @@ void CParticleObject::UpdateClose(void) } } - if ( this->m_nRemoveTimer != 0 && this->m_nRemoveTimer < CTimer::GetTimeInMilliseconds() ) + if ( this->m_nRemoveTimer != 0 ) { MoveToList(&pCloseListHead, &pUnusedListHead, this); this->m_nState = POBJECTSTATE_FREE; @@ -1100,7 +1100,7 @@ void CParticleObject::UpdateClose(void) void CParticleObject::UpdateFar(void) { - if ( this->m_nRemoveTimer != 0 && this->m_nRemoveTimer < CTimer::GetTimeInMilliseconds() ) + if ( this->m_nRemoveTimer != 0 ) { MoveToList(&pFarListHead, &pUnusedListHead, this); this->m_nState = POBJECTSTATE_FREE; diff --git a/src/renderer/Particle.cpp b/src/renderer/Particle.cpp index 9052ef08..81e62e7f 100644 --- a/src/renderer/Particle.cpp +++ b/src/renderer/Particle.cpp @@ -806,6 +806,7 @@ CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVe return AddParticle(type, vecPos, vecDir, pEntity, fSize, color, nRotationSpeed, nRotation, nCurFrame, nLifeSpan); } +float throttleParticleAdd = 0; CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVector const &vecDir, CEntity *pEntity, float fSize, RwRGBA const &color, int32 nRotationSpeed, int32 nRotation, int32 nCurFrame, int32 nLifeSpan) { if ( CTimer::GetIsPaused() ) @@ -831,6 +832,10 @@ CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVe if ( pParticle == nil ) return nil; + throttleParticleAdd += CTimer::GetTimeStepInMilliseconds(); + if(throttleParticleAdd < 31) return nil; + throttleParticleAdd -= 31; + tParticleSystemData *psystem = &mod_ParticleSystemManager.m_aParticles[type]; if ( psystem->m_fCreateRange != 0.0f && psystem->m_fCreateRange < ( TheCamera.GetPosition() - vecPos ).MagnitudeSqr() ) @@ -1039,10 +1044,18 @@ CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVe return pParticle; } +float throttleParticleUpdate = 0; + void CParticle::Update() { if ( CTimer::GetIsPaused() ) return; + + CParticleObject::UpdateAll(); + + throttleParticleUpdate += CTimer::GetTimeStepInMilliseconds(); + if(throttleParticleUpdate < 31) return; + throttleParticleUpdate -= 31; CRGBA color(0, 0, 0, 0); @@ -1053,8 +1066,6 @@ void CParticle::Update() float fFricDeccel96 = 0.96f; float fFricDeccel99 = 0.99f; - CParticleObject::UpdateAll(); - for ( int32 i = 0; i < MAX_PARTICLES; i++ ) { tParticleSystemData *psystem = &mod_ParticleSystemManager.m_aParticles[i]; @@ -1899,4 +1910,4 @@ void CParticle::AddYardieDoorSmoke(CVector const &vecPos, CMatrix const &matMatr nil, 0.3f, color, 0, 0, 0, 0); } -} +} \ No newline at end of file