|
87 | 87 | #endif |
88 | 88 |
|
89 | 89 |
|
90 | | -#define VERY_TRANSPARENT_MATERIAL_PASS_OPACITY (0.001f) |
91 | | -#define MATERIAL_PASS_OPACITY_FADE_SCALAR (0.8f) |
| 90 | +#define MATERIAL_PASS_OPACITY_MIN (0.001f) |
| 91 | +#define MATERIAL_PASS_OPACITY_DEFAULT_FADE_SCALAR (0.8f) |
92 | 92 |
|
93 | 93 | static const char *const TheDrawableIconNames[] = |
94 | 94 | { |
@@ -433,6 +433,8 @@ Drawable::Drawable( const ThingTemplate *thingTemplate, DrawableStatusBits statu |
433 | 433 | m_hidden = false; |
434 | 434 | m_hiddenByStealth = false; |
435 | 435 | m_secondMaterialPassOpacity = 0.0f; |
| 436 | + m_secondMaterialPassOpacityScalar = MATERIAL_PASS_OPACITY_DEFAULT_FADE_SCALAR; |
| 437 | + m_secondMaterialPassOpacityAllowRefill = false; |
436 | 438 | m_drawableFullyObscuredByShroud = false; |
437 | 439 |
|
438 | 440 | m_receivesDynamicLights = TRUE; // a good default... overridden by one of my draw modules if at all |
@@ -2607,17 +2609,37 @@ void Drawable::setStealthLook(StealthLookType look) |
2607 | 2609 | //------------------------------------------------------------------------------------------------- |
2608 | 2610 | void Drawable::draw() |
2609 | 2611 | { |
2610 | | - if ( testTintStatus( TINT_STATUS_FRENZY ) == FALSE ) |
| 2612 | + if (testTintStatus(TINT_STATUS_FRENZY) == FALSE) |
2611 | 2613 | { |
2612 | | - if ( getObject() && getObject()->isEffectivelyDead() ) |
2613 | | - m_secondMaterialPassOpacity = 0.0f;//dead folks don't stealth anyway |
2614 | | - else if ( m_secondMaterialPassOpacity > VERY_TRANSPARENT_MATERIAL_PASS_OPACITY )// keep fading any add'l material unless something has set it to zero |
2615 | | - m_secondMaterialPassOpacity *= MATERIAL_PASS_OPACITY_FADE_SCALAR; |
2616 | | - else |
2617 | | - m_secondMaterialPassOpacity = 0.0f; |
| 2614 | + if (getObject() && getObject()->isEffectivelyDead()) |
| 2615 | + { |
| 2616 | + m_secondMaterialPassOpacity = 0.0f;//dead folks don't stealth anyway |
| 2617 | + } |
| 2618 | + else if (!TheFramePacer->isGameHalted()) |
| 2619 | + { |
| 2620 | + // TheSuperHackers @tweak The opacity step is now decoupled from the render update. |
| 2621 | + if (m_secondMaterialPassOpacity > MATERIAL_PASS_OPACITY_MIN) |
| 2622 | + { |
| 2623 | + m_secondMaterialPassOpacity *= m_secondMaterialPassOpacityScalar; |
| 2624 | + } |
| 2625 | + else if (m_secondMaterialPassOpacityAllowRefill) |
| 2626 | + { |
| 2627 | + // min opacity = (X ^ (framerate / updatesPerSec)) -> e.g. [ 0.05 = X ^ (100 / 2) ] -> [ X = 0.941845 ] -> [ 0.941845 ^ 50 = 0.05 ] |
| 2628 | + // changes to the updates per second value need to be tested with a single stealth detector, max 30 logic frames and unlimited render frames |
| 2629 | + const Real updatesPerSec = 2.0f; |
| 2630 | + const Real scalar = pow(MATERIAL_PASS_OPACITY_MIN, updatesPerSec / TheFramePacer->getUpdateFps()); |
| 2631 | + |
| 2632 | + m_secondMaterialPassOpacity = scalar; |
| 2633 | + m_secondMaterialPassOpacityScalar = scalar; |
| 2634 | + m_secondMaterialPassOpacityAllowRefill = FALSE; |
| 2635 | + } |
| 2636 | + else |
| 2637 | + { |
| 2638 | + m_secondMaterialPassOpacity = 0.0f; |
| 2639 | + } |
| 2640 | + } |
2618 | 2641 | } |
2619 | 2642 |
|
2620 | | - |
2621 | 2643 | if (m_hidden || m_hiddenByStealth || getFullyObscuredByShroud()) |
2622 | 2644 | return; // my, that was easy |
2623 | 2645 |
|
|
0 commit comments