- disabled staggered unit updates

This commit is contained in:
Mark Vejvoda 2010-08-24 02:49:55 +00:00
parent 65cf1bfdac
commit 0e3c0a8d0e
6 changed files with 36 additions and 22 deletions

View File

@ -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()); 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); //if(avgRenderFps >= 10 || world.getFrameCount() % 2 == 0) {
renderer.updateParticleManager(rsGame); //renderer.updateParticleManager(rsGame,lastRenderFps);
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,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__); //good_fpu_control_registers(NULL,__FILE__,__FUNCTION__,__LINE__);
} }
@ -1220,7 +1222,7 @@ void Game::render3d(){
//shadow map //shadow map
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
chrono.start(); 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()); 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 //clear buffers
@ -1232,7 +1234,7 @@ void Game::render3d(){
//surface //surface
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
chrono.start(); 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()); 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 //selection circles
@ -1244,13 +1246,13 @@ void Game::render3d(){
//units //units
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
chrono.start(); 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()); 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 //objects
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
chrono.start(); 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()); 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 //water

View File

@ -475,9 +475,9 @@ void Renderer::manageParticleSystem(ParticleSystem *particleSystem, ResourceScop
} }
void Renderer::updateParticleManager(ResourceScope rs, int renderFps) { void Renderer::updateParticleManager(ResourceScope rs, int renderFps) {
if(renderFps < 0 || renderFps >= MIN_FPS_NORMAL_RENDERING) { //if(renderFps < 0 || renderFps >= MIN_FPS_NORMAL_RENDERING) {
particleManager[rs]->update(); particleManager[rs]->update(renderFps);
} //}
} }
void Renderer::renderParticleManager(ResourceScope rs){ void Renderer::renderParticleManager(ResourceScope rs){

View File

@ -48,7 +48,7 @@ World::World(){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
Config &config= Config::getInstance(); Config &config= Config::getInstance();
staggeredFactionUpdates = true; staggeredFactionUpdates = false;
ExploredCellsLookupItemCache.clear(); ExploredCellsLookupItemCache.clear();
ExploredCellsLookupItemCacheTimer.clear(); ExploredCellsLookupItemCacheTimer.clear();
ExploredCellsLookupItemCacheTimerCount = 0; 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()); if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
//tick //tick
bool needToTick = (frameCount % GameConstants::updateFps == 0); bool needToTick = canTickWorld();
if(staggeredFactionUpdates == true) {
needToTick = (frameCount % (GameConstants::updateFps / GameConstants::maxPlayers) == 0);
}
if(needToTick == true) { if(needToTick == true) {
//if(frameCount % (GameConstants::updateFps / GameConstants::maxPlayers) == 0) { //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()); 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()); 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 World::getUpdateFps(int factionIndex) const {
int result = GameConstants::updateFps; int result = GameConstants::updateFps;
//if(factionIndex != -1 && staggeredFactionUpdates == true) { //if(factionIndex != -1 && staggeredFactionUpdates == true) {

View File

@ -191,6 +191,7 @@ public:
std::string DumpWorldToLog(bool consoleBasicInfoOnly = false) const; std::string DumpWorldToLog(bool consoleBasicInfoOnly = false) const;
int getUpdateFps(int factionIndex) const; int getUpdateFps(int factionIndex) const;
bool canTickWorld() const;
private: private:

View File

@ -430,7 +430,7 @@ private:
public: public:
~ParticleManager(); ~ParticleManager();
void update(); void update(int renderFps=-1);
void render(ParticleRenderer *pr, ModelRenderer *mr) const; void render(ParticleRenderer *pr, ModelRenderer *mr) const;
void manage(ParticleSystem *ps); void manage(ParticleSystem *ps);
void end(); void end();

View File

@ -914,20 +914,24 @@ void ParticleManager::render(ParticleRenderer *pr, ModelRenderer *mr) const{
} }
} }
void ParticleManager::update() { void ParticleManager::update(int renderFps) {
Chrono chrono; Chrono chrono;
chrono.start(); chrono.start();
//const int MIN_FPS_NORMAL_RENDERING = 10;
int particleSystemCount = particleSystems.size(); int particleSystemCount = particleSystems.size();
int particleCount = 0; int particleCount = 0;
list<ParticleSystem*>::iterator it; list<ParticleSystem*>::iterator it;
for (it=particleSystems.begin(); it!=particleSystems.end(); it++) { for (it=particleSystems.begin(); it!=particleSystems.end(); it++) {
particleCount += (*it)->getAliveParticleCount(); particleCount += (*it)->getAliveParticleCount();
(*it)->update(); //if(renderFps < 0 || renderFps >= MIN_FPS_NORMAL_RENDERING ||
if((*it)->isEmpty()) { // dynamic_cast<UnitParticleSystem *>((*it)) == NULL) {
delete *it; (*it)->update();
*it= NULL; if((*it)->isEmpty()) {
} delete *it;
*it= NULL;
}
//}
} }
particleSystems.remove(NULL); particleSystems.remove(NULL);