Skip to content

Commit e0befc8

Browse files
committed
unify(particlesys): Merge optimization of alpha particle update from Zero Hour (TheSuperHackers#2153)
1 parent 69e3d6a commit e0befc8

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

Generals/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -455,26 +455,30 @@ Bool Particle::update( void )
455455
m_sizeRate *= m_sizeRateDamping;
456456

457457
//
458-
// Update alpha
458+
// Update alpha (if used)
459459
//
460-
m_alpha += m_alphaRate;
461460

462-
if (m_alphaTargetKey < MAX_KEYFRAMES && m_alphaKey[ m_alphaTargetKey ].frame)
461+
if (m_system->getShaderType() != ParticleSystemInfo::ADDITIVE)
463462
{
464-
if (TheGameClient->getFrame() - m_createTimestamp >= m_alphaKey[ m_alphaTargetKey ].frame)
463+
m_alpha += m_alphaRate;
464+
465+
if (m_alphaTargetKey < MAX_KEYFRAMES && m_alphaKey[ m_alphaTargetKey ].frame)
465466
{
466-
m_alpha = m_alphaKey[ m_alphaTargetKey ].value;
467-
m_alphaTargetKey++;
468-
computeAlphaRate();
467+
if (TheGameClient->getFrame() - m_createTimestamp >= m_alphaKey[ m_alphaTargetKey ].frame)
468+
{
469+
m_alpha = m_alphaKey[ m_alphaTargetKey ].value;
470+
m_alphaTargetKey++;
471+
computeAlphaRate();
472+
}
469473
}
470-
}
471-
else
472-
m_alphaRate = 0.0f;
474+
else
475+
m_alphaRate = 0.0f;
473476

474-
if (m_alpha < 0.0f)
475-
m_alpha = 0.0f;
476-
else if (m_alpha > 1.0f)
477-
m_alpha = 1.0f;
477+
if (m_alpha < 0.0f)
478+
m_alpha = 0.0f;
479+
else if (m_alpha > 1.0f)
480+
m_alpha = 1.0f;
481+
}
478482

479483

480484
//

0 commit comments

Comments
 (0)