mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 19:00:07 +02:00
- some optimizations for performance logging
This commit is contained in:
@@ -48,6 +48,8 @@ World::World(){
|
|||||||
fogOfWarSmoothing= config.getBool("FogOfWarSmoothing");
|
fogOfWarSmoothing= config.getBool("FogOfWarSmoothing");
|
||||||
fogOfWarSmoothingFrameSkip= config.getInt("FogOfWarSmoothingFrameSkip");
|
fogOfWarSmoothingFrameSkip= config.getInt("FogOfWarSmoothingFrameSkip");
|
||||||
|
|
||||||
|
bool perfTimerEnabled = SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled;
|
||||||
|
|
||||||
frameCount= 0;
|
frameCount= 0;
|
||||||
//nextUnitId= 0;
|
//nextUnitId= 0;
|
||||||
|
|
||||||
@@ -177,18 +179,19 @@ void World::loadScenario(const string &path, Checksum *checksum){
|
|||||||
// ==================== misc ====================
|
// ==================== misc ====================
|
||||||
|
|
||||||
void World::update(){
|
void World::update(){
|
||||||
Chrono chrono;
|
if(perfTimerEnabled == true) {
|
||||||
chrono.start();
|
chronoPerfTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
++frameCount;
|
++frameCount;
|
||||||
|
|
||||||
//time
|
//time
|
||||||
timeFlow.update();
|
timeFlow.update();
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis());
|
||||||
|
|
||||||
//water effects
|
//water effects
|
||||||
waterEffects.update();
|
waterEffects.update();
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis());
|
||||||
|
|
||||||
//units
|
//units
|
||||||
for(int i=0; i<getFactionCount(); ++i){
|
for(int i=0; i<getFactionCount(); ++i){
|
||||||
@@ -196,7 +199,7 @@ void World::update(){
|
|||||||
unitUpdater.updateUnit(getFaction(i)->getUnit(j));
|
unitUpdater.updateUnit(getFaction(i)->getUnit(j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis());
|
||||||
|
|
||||||
//undertake the dead
|
//undertake the dead
|
||||||
for(int i=0; i<getFactionCount(); ++i){
|
for(int i=0; i<getFactionCount(); ++i){
|
||||||
@@ -210,7 +213,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(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis());
|
||||||
|
|
||||||
//food costs
|
//food costs
|
||||||
for(int i=0; i<techTree->getResourceTypeCount(); ++i){
|
for(int i=0; i<techTree->getResourceTypeCount(); ++i){
|
||||||
@@ -221,21 +224,21 @@ 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(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis());
|
||||||
|
|
||||||
//fow smoothing
|
//fow smoothing
|
||||||
if(fogOfWarSmoothing && ((frameCount+1) % (fogOfWarSmoothingFrameSkip+1))==0){
|
if(fogOfWarSmoothing && ((frameCount+1) % (fogOfWarSmoothingFrameSkip+1))==0){
|
||||||
float fogFactor= static_cast<float>(frameCount%GameConstants::updateFps)/GameConstants::updateFps;
|
float fogFactor= static_cast<float>(frameCount%GameConstants::updateFps)/GameConstants::updateFps;
|
||||||
minimap.updateFowTex(clamp(fogFactor, 0.f, 1.f));
|
minimap.updateFowTex(clamp(fogFactor, 0.f, 1.f));
|
||||||
}
|
}
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis());
|
||||||
|
|
||||||
//tick
|
//tick
|
||||||
if(frameCount%GameConstants::updateFps==0){
|
if(frameCount%GameConstants::updateFps==0){
|
||||||
computeFow();
|
computeFow();
|
||||||
tick();
|
tick();
|
||||||
}
|
}
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(perfTimerEnabled == true && chronoPerfTimer.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chronoPerfTimer.getMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::tick(){
|
void World::tick(){
|
||||||
@@ -793,10 +796,9 @@ void World::computeFow(){
|
|||||||
//iterate through all cells
|
//iterate through all cells
|
||||||
PosCircularIterator pci(&map, unit->getPos(), sightRange+indirectSightRange);
|
PosCircularIterator pci(&map, unit->getPos(), sightRange+indirectSightRange);
|
||||||
while(pci.next()){
|
while(pci.next()){
|
||||||
Vec2i pos= pci.getPos();
|
const Vec2i &pos= pci.getPos();
|
||||||
Vec2i surfPos= Map::toSurfCoords(pos);
|
Vec2i surfPos= Map::toSurfCoords(pos);
|
||||||
|
|
||||||
|
|
||||||
//compute max alpha
|
//compute max alpha
|
||||||
float maxAlpha;
|
float maxAlpha;
|
||||||
if(surfPos.x>1 && surfPos.y>1 && surfPos.x<map.getSurfaceW()-2 && surfPos.y<map.getSurfaceH()-2){
|
if(surfPos.x>1 && surfPos.y>1 && surfPos.x<map.getSurfaceW()-2 && surfPos.y<map.getSurfaceH()-2){
|
||||||
|
@@ -91,6 +91,8 @@ private:
|
|||||||
int fogOfWarSmoothingFrameSkip;
|
int fogOfWarSmoothingFrameSkip;
|
||||||
bool fogOfWarSmoothing;
|
bool fogOfWarSmoothing;
|
||||||
Game *game;
|
Game *game;
|
||||||
|
Chrono chronoPerfTimer;
|
||||||
|
bool perfTimerEnabled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
World();
|
World();
|
||||||
|
Reference in New Issue
Block a user