Skip to content

Commit 8e09433

Browse files
committed
tweak(drawable): Decouple material opacity of detected stealth models from render update
Scalar value is NOT calculated ahead of rendering.
1 parent f897c63 commit 8e09433

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,6 @@ class Drawable : public Thing,
545545
inline 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

548-
Real getSecondMaterialPassOpacityScalar() const { return m_secondMaterialPassOpacityScalar; } ///< get alpha/opacity scalar value used to render e.g. detected stealth units.
549-
void setSecondMaterialPassOpacityScalar(Real scalar) { m_secondMaterialPassOpacityScalar = scalar; } ///< set alpha/opacity scalar value used to render e.g. detected stealth units.
550-
551548
// both of these assume that you are starting at one extreme 100% or 0% opacity and are trying to go to the other!! -- amit
552549
void fadeOut( UnsignedInt frames ); ///< fade object out...how gradually this is done is determined by frames
553550
void fadeIn( UnsignedInt frames ); ///< fade object in...how gradually this is done is determined by frames
@@ -727,7 +724,6 @@ class Drawable : public Thing,
727724
DrawableIconInfo* m_iconInfo; ///< lazily allocated!
728725

729726
Real m_secondMaterialPassOpacity; ///< drawable gets rendered again in hardware with an extra material layer
730-
Real m_secondMaterialPassOpacityScalar; ///< multiply opacity by scalar value; used for non-default render framerates
731727
// --------- BYTE-SIZED THINGS GO HERE
732728
Byte m_selected; ///< drawable is selected or not
733729
Bool m_hidden; ///< drawable is "hidden" or not (overrides stealth effects)

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888

8989

9090
#define VERY_TRANSPARENT_MATERIAL_PASS_OPACITY (0.001f)
91-
#define MATERIAL_PASS_OPACITY_FADE_SCALAR (0.8f)
9291

9392
static const char *const TheDrawableIconNames[] =
9493
{
@@ -433,7 +432,6 @@ Drawable::Drawable( const ThingTemplate *thingTemplate, DrawableStatusBits statu
433432
m_hidden = false;
434433
m_hiddenByStealth = false;
435434
m_secondMaterialPassOpacity = 0.0f;
436-
m_secondMaterialPassOpacityScalar = MATERIAL_PASS_OPACITY_FADE_SCALAR;
437435
m_drawableFullyObscuredByShroud = false;
438436

439437
m_receivesDynamicLights = TRUE; // a good default... overridden by one of my draw modules if at all
@@ -2613,8 +2611,14 @@ void Drawable::draw()
26132611
if ( getObject() && getObject()->isEffectivelyDead() )
26142612
m_secondMaterialPassOpacity = 0.0f;//dead folks don't stealth anyway
26152613
else if ( m_secondMaterialPassOpacity > VERY_TRANSPARENT_MATERIAL_PASS_OPACITY )// keep fading any add'l material unless something has set it to zero
2616-
// TheSuperHackers @tweak The opacity step is now decoupled from the render update.
2617-
m_secondMaterialPassOpacity *= m_secondMaterialPassOpacityScalar;
2614+
{
2615+
// TheSuperHackers @tweak The opacity step is now decoupled from the render update.
2616+
// minOpacity = (X ^ (framerate / updatesPerSec)) -> e.g. [ 0.05 = X ^ (100 / 2) ] -> [ X = 0.941845 ] -> [ 0.941845 ^ 50 = 0.05 ]
2617+
constexpr const Real minOpacity = 0.05f;
2618+
constexpr const Real updatesPerSec = 2.0f; // (LOGICFRAMES_PER_MSEC_REAL / data->m_updateRate (15))
2619+
const Real scalar = pow(minOpacity, updatesPerSec / TheFramePacer->getUpdateFps());
2620+
m_secondMaterialPassOpacity *= scalar;
2621+
}
26182622
else
26192623
m_secondMaterialPassOpacity = 0.0f;
26202624
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthDetectorUpdate.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#include "Common/BitFlagsIO.h"
5252
#include "Common/PlayerList.h"
5353
#include "Common/Player.h"
54-
#include "Common/FramePacer.h"
5554

5655

5756
//-------------------------------------------------------------------------------------------------
@@ -309,17 +308,10 @@ UpdateSleepTime StealthDetectorUpdate::update( void )
309308
{
310309
constexpr const Real minOpacity = 0.05f;
311310
constexpr const Real resetThreshold = 2 * minOpacity;
312-
constexpr const Real updatesPerSec = 2.0f; // (LOGICFRAMES_PER_MSEC_REAL / data->m_updateRate (15))
313311

314312
// TheSuperHackers @tweak Reset opacity only below threshold to prevent models flickering from multiple detections or special powers.
315313
if (theirDraw->getSecondMaterialPassOpacity() < resetThreshold)
316-
{
317-
// calculate opacity scalar to get smooth pulsating effect decoupled from the render update
318-
// minOpacity = (X ^ (framerate / updatesPerSec)) -> e.g. [ 0.05 = X ^ (100 / 2) ] -> [ X = 0.941845 ] -> [ 0.941845 ^ 50 = 0.05 ]
319-
const Real scalar = pow(minOpacity, updatesPerSec / TheFramePacer->getUpdateFps());
320-
theirDraw->setSecondMaterialPassOpacityScalar(scalar);
321314
theirDraw->setSecondMaterialPassOpacity(1.0f);
322-
}
323315
}
324316

325317
if (data->m_IRGridParticleSysTmpl)

0 commit comments

Comments
 (0)