Skip to content

Commit a56e83a

Browse files
committed
Changed scalar calculation logic.
1 parent 79ca8b7 commit a56e83a

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ class Drawable : public Thing,
545545
Real getSecondMaterialPassOpacity() const { return m_secondMaterialPassOpacity; } ///< get alpha/opacity value used to render add'l rendering pass.
546546
void setSecondMaterialPassOpacity( Real op ) { m_secondMaterialPassOpacity = op; }; ///< set alpha/opacity value used to render add'l rendering pass.
547547
void allowRefillSecondMaterialPassOpacity() { m_secondMaterialPassOpacityAllowRefill = TRUE; } ///< allow the second material opacity to be set to 1.0f
548+
static void updateSecondMaterialPassOpacityScalar(); ///< update alpha/opacity scalar value used to render e.g. detected stealth units.
548549

549550
// both of these assume that you are starting at one extreme 100% or 0% opacity and are trying to go to the other!! -- amit
550551
void fadeOut( UnsignedInt frames ); ///< fade object out...how gradually this is done is determined by frames
@@ -724,8 +725,9 @@ class Drawable : public Thing,
724725
UnsignedInt m_expirationDate; ///< if nonzero, Drawable should destroy itself at this frame
725726
DrawableIconInfo* m_iconInfo; ///< lazily allocated!
726727

727-
Real m_secondMaterialPassOpacity; ///< drawable gets rendered again in hardware with an extra material layer
728-
Bool m_secondMaterialPassOpacityAllowRefill; ///< allow the second material opacity to be set to 1.0f
728+
static inline Real m_secondMaterialPassOpacityScalar; ///< multiply opacity by scalar value; used for non-default render framerates
729+
Real m_secondMaterialPassOpacity; ///< drawable gets rendered again in hardware with an extra material layer
730+
Bool m_secondMaterialPassOpacityAllowRefill; ///< allow the second material opacity to be set to 1.0f
729731
// --------- BYTE-SIZED THINGS GO HERE
730732
Byte m_selected; ///< drawable is selected or not
731733
Bool m_hidden; ///< drawable is "hidden" or not (overrides stealth effects)

GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,6 +2601,15 @@ void Drawable::setStealthLook(StealthLookType look)
26012601
}
26022602
}
26032603

2604+
void Drawable::updateSecondMaterialPassOpacityScalar()
2605+
{
2606+
// TheSuperHackers @tweak The opacity step is no longer a fixed value.
2607+
// min opacity = (X ^ (frame rate / updates per second)) -> e.g. [ 0.05 = X ^ (100 / 2) ] -> [ X = 0.941845 ] -> [ 0.941845 ^ 50 = 0.05 ]
2608+
const Real updatesPerSec = 2.0f;
2609+
const Real scalar = pow(MATERIAL_PASS_OPACITY_MIN, updatesPerSec / TheFramePacer->getUpdateFps());
2610+
2611+
m_secondMaterialPassOpacityScalar = scalar;
2612+
}
26042613

26052614
//-------------------------------------------------------------------------------------------------
26062615
/** default draw is to just call the database defined draw */
@@ -2615,24 +2624,19 @@ void Drawable::draw()
26152624
}
26162625
else if (!TheFramePacer->isGameHalted())
26172626
{
2618-
// TheSuperHackers @tweak The opacity step is no longer a fixed value.
2619-
const Bool shouldFade = (m_secondMaterialPassOpacity > MATERIAL_PASS_OPACITY_MIN);
2627+
const Bool shouldFade = m_secondMaterialPassOpacity > MATERIAL_PASS_OPACITY_MIN;
26202628
const Bool allowRefill = m_secondMaterialPassOpacityAllowRefill;
26212629

26222630
if (shouldFade || allowRefill)
26232631
{
2624-
// min opacity = (X ^ (frame rate / updates per second)) -> e.g. [ 0.05 = X ^ (100 / 2) ] -> [ X = 0.941845 ] -> [ 0.941845 ^ 50 = 0.05 ]
2625-
const Real updatesPerSec = 2.0f;
2626-
const Real scalar = pow(MATERIAL_PASS_OPACITY_MIN, updatesPerSec / TheFramePacer->getUpdateFps());
2627-
26282632
if (!shouldFade && allowRefill)
26292633
{
2630-
m_secondMaterialPassOpacity = scalar;
2634+
m_secondMaterialPassOpacity = m_secondMaterialPassOpacityScalar;
26312635
m_secondMaterialPassOpacityAllowRefill = FALSE;
26322636
}
26332637
else
26342638
{
2635-
m_secondMaterialPassOpacity *= scalar;
2639+
m_secondMaterialPassOpacity *= m_secondMaterialPassOpacityScalar;
26362640
}
26372641
}
26382642
else

0 commit comments

Comments
 (0)