attempt to squeeze a bit more performance
This commit is contained in:
parent
9625bd77a4
commit
c98a09b905
|
@ -34,8 +34,10 @@ const float Minimap::exploredAlpha= 0.5f;
|
||||||
Minimap::Minimap() {
|
Minimap::Minimap() {
|
||||||
fowPixmap0= NULL;
|
fowPixmap0= NULL;
|
||||||
fowPixmap1= NULL;
|
fowPixmap1= NULL;
|
||||||
|
fowPixmap1_default=NULL;
|
||||||
fowPixmap0Copy = NULL;
|
fowPixmap0Copy = NULL;
|
||||||
fowPixmap1Copy = NULL;
|
fowPixmap1Copy = NULL;
|
||||||
|
fowPixmap1Copy_default = NULL;
|
||||||
fogOfWar= true;
|
fogOfWar= true;
|
||||||
gameSettings= NULL;
|
gameSettings= NULL;
|
||||||
tex=NULL;
|
tex=NULL;
|
||||||
|
@ -63,7 +65,9 @@ void Minimap::init(int w, int h, const World *world, bool fogOfWar) {
|
||||||
fowPixmap0 = new Pixmap2D(potW, potH, 1);
|
fowPixmap0 = new Pixmap2D(potW, potH, 1);
|
||||||
fowPixmap0Copy = new Pixmap2D(potW, potH, 1);
|
fowPixmap0Copy = new Pixmap2D(potW, potH, 1);
|
||||||
fowPixmap1 = new Pixmap2D(potW, potH, 1);
|
fowPixmap1 = new Pixmap2D(potW, potH, 1);
|
||||||
|
fowPixmap1_default = new Pixmap2D(potW, potH, 1);
|
||||||
fowPixmap1Copy = new Pixmap2D(potW, potH, 1);
|
fowPixmap1Copy = new Pixmap2D(potW, potH, 1);
|
||||||
|
fowPixmap1Copy_default = new Pixmap2D(potW, potH, 1);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
@ -120,8 +124,12 @@ Minimap::~Minimap() {
|
||||||
fowPixmap0Copy = NULL;
|
fowPixmap0Copy = NULL;
|
||||||
delete fowPixmap1;
|
delete fowPixmap1;
|
||||||
fowPixmap1=NULL;
|
fowPixmap1=NULL;
|
||||||
|
delete fowPixmap1_default;
|
||||||
|
fowPixmap1_default = NULL;
|
||||||
delete fowPixmap1Copy;
|
delete fowPixmap1Copy;
|
||||||
fowPixmap1Copy=NULL;
|
fowPixmap1Copy=NULL;
|
||||||
|
delete fowPixmap1Copy_default;
|
||||||
|
fowPixmap1Copy_default = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== set ====================
|
// ==================== set ====================
|
||||||
|
@ -143,6 +151,15 @@ void Minimap::incFowTextureAlphaSurface(const Vec2i &sPos, float alpha,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Minimap::copyFowTexAlphaSurface() {
|
||||||
|
fowPixmap1_default->copy(fowPixmap1);
|
||||||
|
fowPixmap1Copy_default->copy(fowPixmap1Copy);
|
||||||
|
}
|
||||||
|
void Minimap::restoreFowTexAlphaSurface() {
|
||||||
|
fowPixmap1->copy(fowPixmap1_default);
|
||||||
|
fowPixmap1Copy->copy(fowPixmap1Copy_default);
|
||||||
|
}
|
||||||
|
|
||||||
void Minimap::setFogOfWar(bool value) {
|
void Minimap::setFogOfWar(bool value) {
|
||||||
fogOfWar = value;
|
fogOfWar = value;
|
||||||
resetFowTex();
|
resetFowTex();
|
||||||
|
|
|
@ -50,8 +50,10 @@ class Minimap{
|
||||||
private:
|
private:
|
||||||
Pixmap2D *fowPixmap0;
|
Pixmap2D *fowPixmap0;
|
||||||
Pixmap2D *fowPixmap1;
|
Pixmap2D *fowPixmap1;
|
||||||
|
Pixmap2D *fowPixmap1_default;
|
||||||
Pixmap2D *fowPixmap0Copy;
|
Pixmap2D *fowPixmap0Copy;
|
||||||
Pixmap2D *fowPixmap1Copy;
|
Pixmap2D *fowPixmap1Copy;
|
||||||
|
Pixmap2D *fowPixmap1Copy_default;
|
||||||
|
|
||||||
Texture2D *tex;
|
Texture2D *tex;
|
||||||
Texture2D *fowTex; //Fog Of War Texture2D
|
Texture2D *fowTex; //Fog Of War Texture2D
|
||||||
|
@ -77,6 +79,9 @@ public:
|
||||||
void copyFowTex();
|
void copyFowTex();
|
||||||
void restoreFowTex();
|
void restoreFowTex();
|
||||||
|
|
||||||
|
void copyFowTexAlphaSurface();
|
||||||
|
void restoreFowTexAlphaSurface();
|
||||||
|
|
||||||
void saveGame(XmlNode *rootNode);
|
void saveGame(XmlNode *rootNode);
|
||||||
void loadGame(const XmlNode *rootNode);
|
void loadGame(const XmlNode *rootNode);
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,8 @@ World::World() {
|
||||||
disableAttackEffects = false;
|
disableAttackEffects = false;
|
||||||
|
|
||||||
loadWorldNode = NULL;
|
loadWorldNode = NULL;
|
||||||
|
cacheFowAlphaTexture = false;
|
||||||
|
cacheFowAlphaTextureFogOfWarValue = false;
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
@ -160,6 +162,8 @@ void World::endScenario() {
|
||||||
fogOfWarOverride = false;
|
fogOfWarOverride = false;
|
||||||
originalGameFogOfWar = fogOfWar;
|
originalGameFogOfWar = fogOfWar;
|
||||||
fogOfWarSkillTypeValue = -1;
|
fogOfWarSkillTypeValue = -1;
|
||||||
|
cacheFowAlphaTexture = false;
|
||||||
|
cacheFowAlphaTextureFogOfWarValue = false;
|
||||||
|
|
||||||
map.end();
|
map.end();
|
||||||
|
|
||||||
|
@ -197,6 +201,8 @@ void World::end(){
|
||||||
fogOfWarSkillTypeValue = -1;
|
fogOfWarSkillTypeValue = -1;
|
||||||
|
|
||||||
map.end();
|
map.end();
|
||||||
|
cacheFowAlphaTexture = false;
|
||||||
|
cacheFowAlphaTextureFogOfWarValue = false;
|
||||||
|
|
||||||
//stats will be deleted by BattleEnd
|
//stats will be deleted by BattleEnd
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -2446,14 +2452,6 @@ bool World::showWorldForPlayer(int factionIndex, bool excludeFogOfWarCheck) cons
|
||||||
void World::computeFow() {
|
void World::computeFow() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
||||||
|
|
||||||
//bool showPerfStats = Config::getInstance().getBool("ShowPerfStats","false");
|
|
||||||
//Chrono chronoPerf;
|
|
||||||
//char perfBuf[8096]="";
|
|
||||||
//std::vector<string> perfList;
|
|
||||||
//if(showPerfStats) chronoPerf.start();
|
|
||||||
|
|
||||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
|
||||||
|
|
||||||
Chrono chronoGamePerformanceCounts;
|
Chrono chronoGamePerformanceCounts;
|
||||||
if(this->game) chronoGamePerformanceCounts.start();
|
if(this->game) chronoGamePerformanceCounts.start();
|
||||||
|
|
||||||
|
@ -2461,16 +2459,21 @@ void World::computeFow() {
|
||||||
|
|
||||||
if(this->game) this->game->addPerformanceCount("world minimap.resetFowTex",chronoGamePerformanceCounts.getMillis());
|
if(this->game) this->game->addPerformanceCount("world minimap.resetFowTex",chronoGamePerformanceCounts.getMillis());
|
||||||
|
|
||||||
// if(showPerfStats) {
|
|
||||||
// sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
|
||||||
// perfList.push_back(perfBuf);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// reset cells
|
// reset cells
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
||||||
|
|
||||||
if(this->game) chronoGamePerformanceCounts.start();
|
if(this->game) chronoGamePerformanceCounts.start();
|
||||||
|
|
||||||
|
// Once we have calculated fog of war texture alpha, they are cached so we
|
||||||
|
// restore the default texture in one shot for speed
|
||||||
|
if(cacheFowAlphaTexture == true) {
|
||||||
|
if(cacheFowAlphaTextureFogOfWarValue != fogOfWar) {
|
||||||
|
cacheFowAlphaTexture = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
minimap.restoreFowTexAlphaSurface();
|
||||||
|
}
|
||||||
|
}
|
||||||
int resetFowAlphaFactionCount = 0;
|
int resetFowAlphaFactionCount = 0;
|
||||||
for(int indexFaction = 0;
|
for(int indexFaction = 0;
|
||||||
indexFaction < GameConstants::maxPlayers + GameConstants::specialFactions;
|
indexFaction < GameConstants::maxPlayers + GameConstants::specialFactions;
|
||||||
|
@ -2483,9 +2486,13 @@ void World::computeFow() {
|
||||||
|
|
||||||
for(int indexSurfaceW = 0; indexSurfaceW < map.getSurfaceW(); ++indexSurfaceW) {
|
for(int indexSurfaceW = 0; indexSurfaceW < map.getSurfaceW(); ++indexSurfaceW) {
|
||||||
for(int indexSurfaceH = 0; indexSurfaceH < map.getSurfaceH(); ++indexSurfaceH) {
|
for(int indexSurfaceH = 0; indexSurfaceH < map.getSurfaceH(); ++indexSurfaceH) {
|
||||||
|
// set all cells to not visible
|
||||||
map.getSurfaceCell(indexSurfaceW, indexSurfaceH)->setVisible(indexFaction, false);
|
map.getSurfaceCell(indexSurfaceW, indexSurfaceH)->setVisible(indexFaction, false);
|
||||||
|
|
||||||
if(showWorldForFaction == true && resetFowAlphaFactionCount <= 1) {
|
// reset fog of ware texture alpha values
|
||||||
|
if(cacheFowAlphaTexture == false &&
|
||||||
|
showWorldForFaction == true &&
|
||||||
|
resetFowAlphaFactionCount <= 1) {
|
||||||
const Vec2i surfPos(indexSurfaceW,indexSurfaceH);
|
const Vec2i surfPos(indexSurfaceW,indexSurfaceH);
|
||||||
|
|
||||||
//compute max alpha
|
//compute max alpha
|
||||||
|
@ -2501,7 +2508,7 @@ void World::computeFow() {
|
||||||
maxAlpha= 0.3f;
|
maxAlpha= 0.3f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//compute alpha
|
// compute alpha
|
||||||
float alpha = maxAlpha;
|
float alpha = maxAlpha;
|
||||||
minimap.incFowTextureAlphaSurface(surfPos, alpha);
|
minimap.incFowTextureAlphaSurface(surfPos, alpha);
|
||||||
}
|
}
|
||||||
|
@ -2511,13 +2518,17 @@ void World::computeFow() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Once we have calculated fog of war texture alpha, will we cache it so that we
|
||||||
|
// can restore it later
|
||||||
|
if(cacheFowAlphaTexture == false) {
|
||||||
|
cacheFowAlphaTexture = true;
|
||||||
|
cacheFowAlphaTextureFogOfWarValue = fogOfWar;
|
||||||
|
minimap.copyFowTexAlphaSurface();
|
||||||
|
}
|
||||||
|
|
||||||
if(this->game) this->game->addPerformanceCount("world reset cells",chronoGamePerformanceCounts.getMillis());
|
if(this->game) this->game->addPerformanceCount("world reset cells",chronoGamePerformanceCounts.getMillis());
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s] Line: %d in frame: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,getFrameCount());
|
||||||
// if(showPerfStats) {
|
|
||||||
// sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
|
||||||
// perfList.push_back(perfBuf);
|
|
||||||
// }
|
|
||||||
|
|
||||||
//compute cells
|
//compute cells
|
||||||
if(this->game) chronoGamePerformanceCounts.start();
|
if(this->game) chronoGamePerformanceCounts.start();
|
||||||
|
@ -2575,17 +2586,6 @@ void World::computeFow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this->game) this->game->addPerformanceCount("world compute cells",chronoGamePerformanceCounts.getMillis());
|
if(this->game) this->game->addPerformanceCount("world compute cells",chronoGamePerformanceCounts.getMillis());
|
||||||
|
|
||||||
// if(showPerfStats) {
|
|
||||||
// sprintf(perfBuf,"In [%s::%s] Line: %d took msecs: " MG_I64_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chronoPerf.getMillis());
|
|
||||||
// perfList.push_back(perfBuf);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(showPerfStats && chronoPerf.getMillis() >= 50) {
|
|
||||||
// for(unsigned int x = 0; x < perfList.size(); ++x) {
|
|
||||||
// printf("%s",perfList[x].c_str());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSettings * World::getGameSettingsPtr() {
|
GameSettings * World::getGameSettingsPtr() {
|
||||||
|
|
|
@ -151,6 +151,9 @@ private:
|
||||||
bool animatedTilesetObjectPosListLoaded;
|
bool animatedTilesetObjectPosListLoaded;
|
||||||
std::vector<Vec2i> animatedTilesetObjectPosList;
|
std::vector<Vec2i> animatedTilesetObjectPosList;
|
||||||
|
|
||||||
|
bool cacheFowAlphaTexture;
|
||||||
|
bool cacheFowAlphaTextureFogOfWarValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
World();
|
World();
|
||||||
~World();
|
~World();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user