Refactor fulldetail override

This commit is contained in:
kaetemi 2013-07-04 22:18:19 +02:00
parent 362024aff3
commit ee227aaf9c
4 changed files with 66 additions and 38 deletions

View file

@ -542,7 +542,7 @@ void renderSceneScreenShot (uint left, uint right, uint top, uint bottom, uint s
CCameraBackup cbScene = setupCameraForScreenshot(*Scene, left, right, top, bottom, screenShotWidth, screenShotHeight);
CCameraBackup cbCanopy = setupCameraForScreenshot(*SceneRoot, left, right, top, bottom, screenShotWidth, screenShotHeight);
// sky setup are copied from main scene before rendering so no setup done here
renderAll(ClientCfg.ScreenShotFullDetail);
renderScene(ClientCfg.ScreenShotFullDetail);
restoreCamera(*Scene, cbScene);
restoreCamera(*SceneRoot, cbCanopy);
}

View file

@ -95,11 +95,11 @@ public:
private:
// renderAll is called in main loop. It can called beginRenderLandscapePolyPart and renderLandscapePolyPart
// renderScene is called in main loop. It can called beginRenderLandscapePolyPart and renderLandscapePolyPart
// methods.
friend void renderAll(bool);
friend void renderScene();
// Enable stencil test and initialize function and operation of stencil at the beginning of renderAll method,
// Enable stencil test and initialize function and operation of stencil at the beginning of renderScene method,
// before opaque render of canopy and main scene parts.
// The eighth bit will be written with a 0 during next render to mark stencil buffer parts which will
// support Shadow Volume algorithm.

View file

@ -487,10 +487,55 @@ static void renderSkyPart(UScene::TRenderPart renderPart, TSkyMode skyMode)
#endif
}
struct CForceFullDetail
{
public:
void backup()
{
maxFullDetailChar = Scene->getMaxSkeletonsInNotCLodForm();
oldBalancingMode = Scene->getPolygonBalancingMode();
oldSkyBalancingMode = UScene::PolygonBalancingOff;
UScene *skyScene = getSkyScene();
if (skyScene) oldSkyBalancingMode = skyScene->getPolygonBalancingMode();
}
void set()
{
Scene->setMaxSkeletonsInNotCLodForm(1000000);
Scene->setPolygonBalancingMode(UScene::PolygonBalancingOff);
UScene *skyScene = getSkyScene();
if (skyScene) skyScene->setPolygonBalancingMode(UScene::PolygonBalancingOff);
}
void restore()
{
Scene->setMaxSkeletonsInNotCLodForm(maxFullDetailChar);
Scene->setPolygonBalancingMode(oldBalancingMode);
UScene *skyScene = getSkyScene();
if (skyScene) skyScene->setPolygonBalancingMode(oldSkyBalancingMode);
}
private:
uint maxFullDetailChar;
UScene::TPolygonBalancingMode oldBalancingMode;
UScene::TPolygonBalancingMode oldSkyBalancingMode;
};
static CForceFullDetail s_ForceFullDetail;
void renderScene(bool forceFullDetail)
{
if (forceFullDetail)
{
s_ForceFullDetail.backup();
s_ForceFullDetail.set();
}
renderScene();
if (forceFullDetail)
{
s_ForceFullDetail.restore();
}
}
// ***************************************************************************************************************************
// Render all scenes
void renderAll(bool forceFullDetail)
void renderScene()
{
if (ClientCfg.Bloom)
{
@ -501,26 +546,6 @@ void renderAll(bool forceFullDetail)
CBloomEffect::getInstance().initBloom();
}
// backup old balancing mode
uint maxFullDetailChar = Scene->getMaxSkeletonsInNotCLodForm();
UScene *skyScene = getSkyScene();
UScene::TPolygonBalancingMode oldBalancingMode = Scene->getPolygonBalancingMode();
UScene::TPolygonBalancingMode oldSkyBalancingMode = UScene::PolygonBalancingOff;
if (skyScene)
{
oldSkyBalancingMode = skyScene->getPolygonBalancingMode();
}
// disable load balancing for that frame only if asked
if (forceFullDetail)
{
Scene->setMaxSkeletonsInNotCLodForm(1000000);
Scene->setPolygonBalancingMode(UScene::PolygonBalancingOff);
if (skyScene)
{
skyScene->setPolygonBalancingMode(UScene::PolygonBalancingOff);
}
}
{
H_AUTO_USE ( RZ_Client_Main_Loop_Sky_And_Weather )
@ -649,17 +674,6 @@ void renderAll(bool forceFullDetail)
// reset depth range
Driver->setDepthRange(0.f, CANOPY_DEPTH_RANGE_START);
// restore load balancing mode
if (forceFullDetail)
{
Scene->setMaxSkeletonsInNotCLodForm(maxFullDetailChar);
Scene->setPolygonBalancingMode(oldBalancingMode);
if (skyScene)
{
skyScene->setPolygonBalancingMode(oldSkyBalancingMode);
}
}
// apply bloom effect
if (ClientCfg.Bloom)
CBloomEffect::getInstance().endBloom();
@ -1524,7 +1538,20 @@ bool mainLoop()
Scene->updateWaterEnvMaps(TimeInSec - FirstTimeInSec);
}
#endif
renderAll(ScreenshotRequest != ScreenshotRequestNone && ClientCfg.ScreenShotFullDetail); // nb : force full detail if a screenshot is asked
// nb : force full detail if a screenshot is asked
// todo : move outside render code
bool fullDetail = ScreenshotRequest != ScreenshotRequestNone && ClientCfg.ScreenShotFullDetail;
if (fullDetail)
{
s_ForceFullDetail.backup();
s_ForceFullDetail.set();
}
renderScene();
if (fullDetail)
{
s_ForceFullDetail.restore();
}
// for that frame and
// tmp : display height grid

View file

@ -29,7 +29,8 @@ const uint NUM_MISSION_OPTIONS = 8;
bool mainLoop();
// render all
void renderAll(bool forceFullDetail = false);
void renderScene();
void renderScene(bool forceFullDetail);
void setDefaultChatWindow(CChatWindow *defaultChatWindow);
void updateDayNightCycleHour();