From 4b2ea661cca84234f7e29153461653aa934cce54 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 4 Jul 2013 00:42:06 +0200 Subject: [PATCH] Fix particles being animated twice in stereo render, see #43 --- code/nel/include/nel/3d/scene.h | 3 ++- code/nel/src/3d/scene.cpp | 14 +++++++++++++- code/snowballs2/client/src/camera.cpp | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/code/nel/include/nel/3d/scene.h b/code/nel/include/nel/3d/scene.h index 1d54ce7a6..e0648ebd3 100644 --- a/code/nel/include/nel/3d/scene.h +++ b/code/nel/include/nel/3d/scene.h @@ -826,7 +826,8 @@ private: void flushSSSModelRequests(); // common vb for water display CVertexBuffer _WaterVB; - + + bool _RequestParticlesAnimate; }; diff --git a/code/nel/src/3d/scene.cpp b/code/nel/src/3d/scene.cpp index f257c7206..76761bc71 100644 --- a/code/nel/src/3d/scene.cpp +++ b/code/nel/src/3d/scene.cpp @@ -191,6 +191,8 @@ CScene::CScene(bool bSmallScene) : LightTrav(bSmallScene) _WaterEnvMap = NULL; _GlobalSystemTime= 0.0; + + _RequestParticlesAnimate = false; } // *************************************************************************** void CScene::release() @@ -381,6 +383,9 @@ void CScene::endPartRender() drv->activeVertexProgram(NULL); drv->activePixelProgram(NULL); + // Ensure nothing animates on subsequent renders + _EllapsedTime = 0.f; + /* uint64 total = PSStatsRegisterPSModelObserver + PSStatsRemovePSModelObserver + @@ -617,7 +622,11 @@ void CScene::renderPart(UScene::TRenderPart rp, bool doHrcPass) // loadBalance LoadBalancingTrav.traverse(); // - _ParticleSystemManager.processAnimate(_EllapsedTime); // deals with permanently animated particle systems + if (_RequestParticlesAnimate) + { + _ParticleSystemManager.processAnimate(_EllapsedTime); // deals with permanently animated particle systems + _RequestParticlesAnimate = false; + } // Light LightTrav.traverse(); } @@ -863,6 +872,9 @@ void CScene::animate( TGlobalAnimationTime atTime ) // Rendered part are invalidate _RenderedPart = UScene::RenderNothing; + + // Particles are animated later due to dependencies + _RequestParticlesAnimate = true; } diff --git a/code/snowballs2/client/src/camera.cpp b/code/snowballs2/client/src/camera.cpp index 42c3b0e4d..28ce273bb 100644 --- a/code/snowballs2/client/src/camera.cpp +++ b/code/snowballs2/client/src/camera.cpp @@ -219,7 +219,8 @@ void releaseSky() // -- -- random note: update and render makes more sense than animate and update void animateSky(double dt) { - if (!StereoDisplay) Clouds->anim(dt); + if (!StereoHMD) Clouds->anim(dt); + SkyScene->animate(AnimationTime); } // this is actually render @@ -232,7 +233,6 @@ void updateSky() skyCameraMatrix.setPos(CVector::Null); SkyCamera.setMatrix(skyCameraMatrix); - SkyScene->animate(AnimationTime); SkyScene->render(); // Must clear ZBuffer For incoming rendering. Driver->clearZBuffer();