From 0e3c0a8d0e56178909d83d7174546dd13233b7d4 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 24 Aug 2010 02:49:55 +0000 Subject: [PATCH] - disabled staggered unit updates --- source/glest_game/game/game.cpp | 16 +++++++++------- source/glest_game/graphics/renderer.cpp | 6 +++--- source/glest_game/world/world.cpp | 17 ++++++++++++----- source/glest_game/world/world.h | 1 + source/shared_lib/include/graphics/particle.h | 2 +- source/shared_lib/sources/graphics/particle.cpp | 16 ++++++++++------ 6 files changed, 36 insertions(+), 22 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index bd5da643..c8c7958b 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -558,9 +558,11 @@ void Game::update(){ if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); - //renderer.updateParticleManager(rsGame,lastRenderFps); - renderer.updateParticleManager(rsGame); - if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //if(avgRenderFps >= 10 || world.getFrameCount() % 2 == 0) { + //renderer.updateParticleManager(rsGame,lastRenderFps); + renderer.updateParticleManager(rsGame,avgRenderFps); + if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); + //} //good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__); } @@ -1220,7 +1222,7 @@ void Game::render3d(){ //shadow map //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); chrono.start(); - renderer.renderShadowsToTexture(lastRenderFps); + renderer.renderShadowsToTexture(avgRenderFps); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); //clear buffers @@ -1232,7 +1234,7 @@ void Game::render3d(){ //surface //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); chrono.start(); - renderer.renderSurface(lastRenderFps,world.getFrameCount()); + renderer.renderSurface(avgRenderFps,world.getFrameCount()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); //selection circles @@ -1244,13 +1246,13 @@ void Game::render3d(){ //units //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); chrono.start(); - renderer.renderUnits(lastRenderFps,world.getFrameCount()); + renderer.renderUnits(avgRenderFps,world.getFrameCount()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); //objects //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); chrono.start(); - renderer.renderObjects(lastRenderFps,world.getFrameCount()); + renderer.renderObjects(avgRenderFps,world.getFrameCount()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis()); //water diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 9ff58312..0da57d90 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -475,9 +475,9 @@ void Renderer::manageParticleSystem(ParticleSystem *particleSystem, ResourceScop } void Renderer::updateParticleManager(ResourceScope rs, int renderFps) { - if(renderFps < 0 || renderFps >= MIN_FPS_NORMAL_RENDERING) { - particleManager[rs]->update(); - } + //if(renderFps < 0 || renderFps >= MIN_FPS_NORMAL_RENDERING) { + particleManager[rs]->update(renderFps); + //} } void Renderer::renderParticleManager(ResourceScope rs){ diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 7388855b..a3cc92f3 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -48,7 +48,7 @@ World::World(){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); Config &config= Config::getInstance(); - staggeredFactionUpdates = true; + staggeredFactionUpdates = false; ExploredCellsLookupItemCache.clear(); ExploredCellsLookupItemCacheTimer.clear(); ExploredCellsLookupItemCacheTimerCount = 0; @@ -346,10 +346,7 @@ void World::update(){ if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); //tick - bool needToTick = (frameCount % GameConstants::updateFps == 0); - if(staggeredFactionUpdates == true) { - needToTick = (frameCount % (GameConstants::updateFps / GameConstants::maxPlayers) == 0); - } + bool needToTick = canTickWorld(); if(needToTick == true) { //if(frameCount % (GameConstants::updateFps / GameConstants::maxPlayers) == 0) { if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); @@ -358,6 +355,16 @@ void World::update(){ if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); } +bool World::canTickWorld() const { + //tick + bool needToTick = (frameCount % GameConstants::updateFps == 0); + if(staggeredFactionUpdates == true) { + needToTick = (frameCount % (GameConstants::updateFps / GameConstants::maxPlayers) == 0); + } + + return needToTick; +} + int World::getUpdateFps(int factionIndex) const { int result = GameConstants::updateFps; //if(factionIndex != -1 && staggeredFactionUpdates == true) { diff --git a/source/glest_game/world/world.h b/source/glest_game/world/world.h index f6becdea..d0a956a4 100644 --- a/source/glest_game/world/world.h +++ b/source/glest_game/world/world.h @@ -191,6 +191,7 @@ public: std::string DumpWorldToLog(bool consoleBasicInfoOnly = false) const; int getUpdateFps(int factionIndex) const; + bool canTickWorld() const; private: diff --git a/source/shared_lib/include/graphics/particle.h b/source/shared_lib/include/graphics/particle.h index 1d16b9b7..0e2ee474 100644 --- a/source/shared_lib/include/graphics/particle.h +++ b/source/shared_lib/include/graphics/particle.h @@ -430,7 +430,7 @@ private: public: ~ParticleManager(); - void update(); + void update(int renderFps=-1); void render(ParticleRenderer *pr, ModelRenderer *mr) const; void manage(ParticleSystem *ps); void end(); diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index 329eebb9..e00d5cf0 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -914,20 +914,24 @@ void ParticleManager::render(ParticleRenderer *pr, ModelRenderer *mr) const{ } } -void ParticleManager::update() { +void ParticleManager::update(int renderFps) { Chrono chrono; chrono.start(); + //const int MIN_FPS_NORMAL_RENDERING = 10; int particleSystemCount = particleSystems.size(); int particleCount = 0; list::iterator it; for (it=particleSystems.begin(); it!=particleSystems.end(); it++) { particleCount += (*it)->getAliveParticleCount(); - (*it)->update(); - if((*it)->isEmpty()) { - delete *it; - *it= NULL; - } + //if(renderFps < 0 || renderFps >= MIN_FPS_NORMAL_RENDERING || + // dynamic_cast((*it)) == NULL) { + (*it)->update(); + if((*it)->isEmpty()) { + delete *it; + *it= NULL; + } + //} } particleSystems.remove(NULL);