From bf8ad82e210d158902a12b787f56bd367aa6847b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 4 Jul 2013 22:39:05 +0200 Subject: [PATCH] Pull weather updates out of scene render --HG-- branch : multipass-stereo --- code/ryzom/client/src/main_loop.cpp | 105 +++++++++++++++------------- 1 file changed, 58 insertions(+), 47 deletions(-) diff --git a/code/ryzom/client/src/main_loop.cpp b/code/ryzom/client/src/main_loop.cpp index 8cd0aea63..95fd7086e 100644 --- a/code/ryzom/client/src/main_loop.cpp +++ b/code/ryzom/client/src/main_loop.cpp @@ -550,73 +550,81 @@ void renderScene(bool forceFullDetail, bool bloom) } // *************************************************************************************************************************** -// Render all scenes -void renderScene() + +void updateWeather() { - { - H_AUTO_USE ( RZ_Client_Main_Loop_Sky_And_Weather ) + H_AUTO_USE ( RZ_Client_Main_Loop_Sky_And_Weather ) - //HeightGrid.update(Scene->getCam().getPos()); + //HeightGrid.update(Scene->getCam().getPos()); - // update description of light cycle - updateLightDesc(); + // update description of light cycle + updateLightDesc(); - // server driven weather mgt - updateDBDrivenWeatherValue(); + // server driven weather mgt + updateDBDrivenWeatherValue(); - // Update the weather manager - updateWeatherManager(MainCam.getMatrix(), ContinentMngr.cur()); + // Update the weather manager + updateWeatherManager(MainCam.getMatrix(), ContinentMngr.cur()); - // compute thunder color - ThunderColor.modulateFromui(WeatherManager.getCurrWeatherState().ThunderColor, (uint) (256.f * WeatherManager.getThunderLevel())); + // compute thunder color + ThunderColor.modulateFromui(WeatherManager.getCurrWeatherState().ThunderColor, (uint) (256.f * WeatherManager.getThunderLevel())); - // Update the lighting - LightCycleManager.setHour(DayNightCycleHour, WeatherManager, ThunderColor); + // Update the lighting + LightCycleManager.setHour(DayNightCycleHour, WeatherManager, ThunderColor); - #ifdef RENDER_CLOUDS - if (Filter3D[FilterCloud]) - { - H_AUTO_USE ( RZ_Client_Main_Loop_Update_Cloud_Scape ); - updateClouds(); - } - #endif + #ifdef RENDER_CLOUDS + if (Filter3D[FilterCloud]) + { + H_AUTO_USE ( RZ_Client_Main_Loop_Update_Cloud_Scape ); + updateClouds(); + } + #endif + + ContinentMngr.getFogState(MainFog, LightCycleManager.getLightLevel(), LightCycleManager.getLightDesc().DuskRatio, LightCycleManager.getState(), View.viewPos(), MainFogState); + // TODO: ZBuffer clear was originally before this, but should not be necessary normally. + // The anim function renders new clouds. Ensure this does not break. + // These are old-style nel clouds. - ContinentMngr.getFogState(MainFog, LightCycleManager.getLightLevel(), LightCycleManager.getLightDesc().DuskRatio, LightCycleManager.getState(), View.viewPos(), MainFogState); + #ifdef RENDER_CLOUDS + if (CloudScape != NULL && Filter3D[FilterCloud]) + { + H_AUTO_USE ( RZ_Client_Main_Loop_Anim_Cloud_Scape ); - if (Driver->getPolygonMode() == UDriver::Filled) - { - Driver->clearZBuffer(); - } + Driver->enableFog (false); - #ifdef RENDER_CLOUDS - if (CloudScape != NULL && Filter3D[FilterCloud]) - { - H_AUTO_USE ( RZ_Client_Main_Loop_Anim_Cloud_Scape ); + // Force polygon mode to filled + NL3D::UDriver::TPolygonMode oldMode = Driver->getPolygonMode(); + Driver->setPolygonMode(NL3D::UDriver::Filled); - Driver->enableFog (false); + CloudScape->anim (DT); // WARNING this function work with screen - // Force polygon mode to filled - NL3D::UDriver::TPolygonMode oldMode = Driver->getPolygonMode(); - Driver->setPolygonMode(NL3D::UDriver::Filled); + Driver->enableFog (true); - CloudScape->anim (DT); // WARNING this function work with screen + // Reset backuped polygon mode + Driver->setPolygonMode(oldMode); + } + #endif +} - Driver->enableFog (true); +// *************************************************************************************************************************** +// Render all scenes +void renderScene() +{ + if (Driver->getPolygonMode() == UDriver::Filled) + { + Driver->clearZBuffer(); + } - // Reset backuped polygon mode - Driver->setPolygonMode(oldMode); - } - #endif - // Sky is used to clear the frame buffer now, but if in line or point polygon mode, we should draw it - if (Driver->getPolygonMode() != UDriver::Filled) + // Sky is used to clear the frame buffer now, but if in line or point polygon mode, we should draw it + if (Driver->getPolygonMode() != UDriver::Filled) + { + if (!Driver->isLost()) { - if (!Driver->isLost()) - { - Driver->clearBuffers (CRGBA(127, 127, 127)); - } + Driver->clearBuffers (CRGBA(127, 127, 127)); } } + // Update Filter Flags Scene->enableElementRender(UScene::FilterAllMeshNoVP, Filter3D[FilterMeshNoVP]); Scene->enableElementRender(UScene::FilterAllMeshVP, Filter3D[FilterMeshVP]); @@ -1541,6 +1549,9 @@ bool mainLoop() Scene->updateWaterEnvMaps(TimeInSec - FirstTimeInSec); } #endif + + // TODO: Verify that moving this out of renderScene does not negatively impact oversize screenshots. + updateWeather(); if (ClientCfg.Bloom) {