Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/GameLOD.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class GameLODManager
bool m_userHeatEffectsEnabled;
bool m_isQualityReduced;
int m_stableFPSDuration;
int m_lowFPSSecondsCount;
DynamicGameLODLevel m_userDynamicLOD;
#endif
};
Expand Down
16 changes: 11 additions & 5 deletions GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ GameLODManager::GameLODManager(void)
m_userHeatEffectsEnabled = true;
m_isQualityReduced = false;
m_stableFPSDuration = 0;
m_lowFPSSecondsCount = 0;
m_userDynamicLOD = DYNAMIC_GAME_LOD_VERY_HIGH;
#endif

Expand Down Expand Up @@ -810,22 +811,27 @@ void GameLODManager::updateGraphicsQualityState(float averageFPS)
m_userDynamicLOD = m_currentDynamicLOD;
}

m_stableFPSDuration = (averageFPS > 56.0f) ? (m_stableFPSDuration + 1) : 0; // Track a duration of sustained good performance
if (averageFPS < 56.0f)
m_lowFPSSecondsCount++, m_stableFPSDuration = 0;
else if (averageFPS > 57.0f)
m_stableFPSDuration++, m_lowFPSSecondsCount = 0;

bool shouldReduceQuality = (averageFPS < 56.0f && TheGameClient && TheGameClient->getFrame() > LOGICFRAMES_PER_SECOND * 10 && !TheShell->isShellActive());
bool shouldReduceQuality = (m_lowFPSSecondsCount >= 2 && TheGameClient && TheGameClient->getFrame() > LOGICFRAMES_PER_SECOND * 10 && !TheShell->isShellActive());
if (shouldReduceQuality && !m_isQualityReduced)
{
if (averageFPS < 50.0f)
m_dynamicGameLODInfo[DYNAMIC_GAME_LOD_LOW].m_minDynamicParticlePriority = ALWAYS_RENDER;
else
if (averageFPS < 56.0f)
m_dynamicGameLODInfo[DYNAMIC_GAME_LOD_LOW].m_minDynamicParticlePriority = WEAPON_TRAIL;
if (averageFPS < 40.0f)
m_dynamicGameLODInfo[DYNAMIC_GAME_LOD_LOW].m_minDynamicParticlePriority = ALWAYS_RENDER;


setDynamicLODLevel(DYNAMIC_GAME_LOD_LOW);
TheGameClient->releaseShadows();
TheWritableGlobalData->m_useShadowVolumes = false;
TheWritableGlobalData->m_useShadowDecals = false;
TheWritableGlobalData->m_useHeatEffects = false;
m_isQualityReduced = true;
m_lowFPSSecondsCount = 0;
}

// Restore to user preferences after sustained good performance
Expand Down
Loading