Throttle particles
This commit is contained in:
@@ -159,7 +159,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
|
|||||||
pobj->m_pParticle = NULL;
|
pobj->m_pParticle = NULL;
|
||||||
|
|
||||||
if ( lifeTime != 0 )
|
if ( lifeTime != 0 )
|
||||||
pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + lifeTime;
|
pobj->m_nRemoveTimer = lifeTime;
|
||||||
else
|
else
|
||||||
pobj->m_nRemoveTimer = 0;
|
pobj->m_nRemoveTimer = 0;
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
|
|||||||
pobj->m_nSkipFrames = 1;
|
pobj->m_nSkipFrames = 1;
|
||||||
pobj->m_nCreationChance = 0;
|
pobj->m_nCreationChance = 0;
|
||||||
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.3f);
|
pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.3f);
|
||||||
pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + 5000;
|
pobj->m_nRemoveTimer = 5000;
|
||||||
CAudioHydrant::Add(pobj);
|
CAudioHydrant::Add(pobj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -373,7 +373,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
|
|||||||
pobj->m_nNumEffectCycles = 1;
|
pobj->m_nNumEffectCycles = 1;
|
||||||
pobj->m_nSkipFrames = 1;
|
pobj->m_nSkipFrames = 1;
|
||||||
pobj->m_nCreationChance = 0;
|
pobj->m_nCreationChance = 0;
|
||||||
pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds();
|
pobj->m_nRemoveTimer = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +384,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe
|
|||||||
pobj->m_nNumEffectCycles = 1;
|
pobj->m_nNumEffectCycles = 1;
|
||||||
pobj->m_nSkipFrames = 1;
|
pobj->m_nSkipFrames = 1;
|
||||||
pobj->m_nCreationChance = 0;
|
pobj->m_nCreationChance = 0;
|
||||||
pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds();
|
pobj->m_nRemoveTimer = 0;
|
||||||
pobj->m_vecTarget.Normalise();
|
pobj->m_vecTarget.Normalise();
|
||||||
break;
|
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;
|
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);
|
MoveToList(&pCloseListHead, &pUnusedListHead, this);
|
||||||
this->m_nState = POBJECTSTATE_FREE;
|
this->m_nState = POBJECTSTATE_FREE;
|
||||||
@@ -1100,7 +1100,7 @@ void CParticleObject::UpdateClose(void)
|
|||||||
void
|
void
|
||||||
CParticleObject::UpdateFar(void)
|
CParticleObject::UpdateFar(void)
|
||||||
{
|
{
|
||||||
if ( this->m_nRemoveTimer != 0 && this->m_nRemoveTimer < CTimer::GetTimeInMilliseconds() )
|
if ( this->m_nRemoveTimer != 0 )
|
||||||
{
|
{
|
||||||
MoveToList(&pFarListHead, &pUnusedListHead, this);
|
MoveToList(&pFarListHead, &pUnusedListHead, this);
|
||||||
this->m_nState = POBJECTSTATE_FREE;
|
this->m_nState = POBJECTSTATE_FREE;
|
||||||
|
|||||||
@@ -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);
|
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)
|
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() )
|
if ( CTimer::GetIsPaused() )
|
||||||
@@ -831,6 +832,10 @@ CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVe
|
|||||||
if ( pParticle == nil )
|
if ( pParticle == nil )
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
|
throttleParticleAdd += CTimer::GetTimeStepInMilliseconds();
|
||||||
|
if(throttleParticleAdd < 31) return nil;
|
||||||
|
throttleParticleAdd -= 31;
|
||||||
|
|
||||||
tParticleSystemData *psystem = &mod_ParticleSystemManager.m_aParticles[type];
|
tParticleSystemData *psystem = &mod_ParticleSystemManager.m_aParticles[type];
|
||||||
|
|
||||||
if ( psystem->m_fCreateRange != 0.0f && psystem->m_fCreateRange < ( TheCamera.GetPosition() - vecPos ).MagnitudeSqr() )
|
if ( psystem->m_fCreateRange != 0.0f && psystem->m_fCreateRange < ( TheCamera.GetPosition() - vecPos ).MagnitudeSqr() )
|
||||||
@@ -1039,11 +1044,19 @@ CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVe
|
|||||||
return pParticle;
|
return pParticle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float throttleParticleUpdate = 0;
|
||||||
|
|
||||||
void CParticle::Update()
|
void CParticle::Update()
|
||||||
{
|
{
|
||||||
if ( CTimer::GetIsPaused() )
|
if ( CTimer::GetIsPaused() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CParticleObject::UpdateAll();
|
||||||
|
|
||||||
|
throttleParticleUpdate += CTimer::GetTimeStepInMilliseconds();
|
||||||
|
if(throttleParticleUpdate < 31) return;
|
||||||
|
throttleParticleUpdate -= 31;
|
||||||
|
|
||||||
CRGBA color(0, 0, 0, 0);
|
CRGBA color(0, 0, 0, 0);
|
||||||
|
|
||||||
float fFricDeccel50 = 0.50f;
|
float fFricDeccel50 = 0.50f;
|
||||||
@@ -1053,8 +1066,6 @@ void CParticle::Update()
|
|||||||
float fFricDeccel96 = 0.96f;
|
float fFricDeccel96 = 0.96f;
|
||||||
float fFricDeccel99 = 0.99f;
|
float fFricDeccel99 = 0.99f;
|
||||||
|
|
||||||
CParticleObject::UpdateAll();
|
|
||||||
|
|
||||||
for ( int32 i = 0; i < MAX_PARTICLES; i++ )
|
for ( int32 i = 0; i < MAX_PARTICLES; i++ )
|
||||||
{
|
{
|
||||||
tParticleSystemData *psystem = &mod_ParticleSystemManager.m_aParticles[i];
|
tParticleSystemData *psystem = &mod_ParticleSystemManager.m_aParticles[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user