diff --git a/source/glest_game/ai/path_finder.h b/source/glest_game/ai/path_finder.h index 46a0af78..1797c925 100644 --- a/source/glest_game/ai/path_finder.h +++ b/source/glest_game/ai/path_finder.h @@ -323,9 +323,9 @@ private: std::map cameFrom, std::map , bool> canAddNode, Unit *& unit, int & maxNodeCount, int curFrameIndex) { - Chrono chrono; + //Chrono chrono; //if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start(); - chrono.start(); + //chrono.start(); FactionState &factionState = factions[unitFactionIndex]; while(nodeLimitReached == false) { @@ -339,6 +339,24 @@ private: pathFound = true; break; } + // Attempt to speed up pathfinding, only count up found path nodes + // to the # we need till we will refresh anyways + else { + //build next pointers + int currentPathNodeCount = 0; + Node *currNode= node; + while(currNode->prev != NULL) { + currentPathNodeCount++; + currNode->prev->next= currNode; + currNode= currNode->prev; + } + + if(currentPathNodeCount > PathFinder::pathFindRefresh) { + pathFound = true; + break; + } + } + if(tryJPSPathfinder == true) { closedNodes[node->pos] = true; } @@ -401,9 +419,9 @@ private: //!!! //if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled == true && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld nodeLimitReached = %d whileLoopCount = %d nodePoolCount = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),nodeLimitReached,whileLoopCount,factionState.nodePoolCount); - if(chrono.getMillis() > 1) { + //if(chrono.getMillis() > 1) { //printf("AStar for unit [%d - %s] took msecs: %lld nodeLimitReached = %d whileLoopCount = %d nodePoolCount = %d curFrameIndex = %d travel distance = %f\n",unit->getId(),unit->getFullName().c_str(), (long long int)chrono.getMillis(),nodeLimitReached,whileLoopCount,factionState.nodePoolCount,curFrameIndex,unit->getPos().dist(finalPos)); - } + //} } }; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 01d85b49..25a43440 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -4399,7 +4399,6 @@ void Renderer::renderWater() { return; } - bool closed= false; const World *world= game->getWorld(); const Map *map= world->getMap(); @@ -4419,7 +4418,7 @@ void Renderer::renderWater() { glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); - if(textures3D){ + if(textures3D) { Texture3D *waterTex= world->getTileset()->getWaterTex(); if(waterTex == NULL) { throw megaglest_runtime_error("waterTex == NULL"); @@ -4444,6 +4443,10 @@ void Renderer::renderWater() { assertGl(); + int thisTeamIndex= world->getThisTeamIndex(); + bool cellExplored = world->showWorldForPlayer(world->getThisFactionIndex()); + bool closed= false; + Rect2i boundingRect= visibleQuad.computeBoundingRect(); Rect2i scaledRect= boundingRect/Map::cellScale; scaledRect.clamp(0, 0, map->getSurfaceW()-1, map->getSurfaceH()-1); @@ -4453,7 +4456,6 @@ void Renderer::renderWater() { glBegin(GL_TRIANGLE_STRIP); for(int i=scaledRect.p[0].x; i<=scaledRect.p[1].x; ++i){ - SurfaceCell *tc0= map->getSurfaceCell(i, j); SurfaceCell *tc1= map->getSurfaceCell(i, j+1); if(tc0 == NULL) { @@ -4463,14 +4465,11 @@ void Renderer::renderWater() { throw megaglest_runtime_error("tc1 == NULL"); } - int thisTeamIndex= world->getThisTeamIndex(); - - bool cellExplored = world->showWorldForPlayer(world->getThisFactionIndex()); if(cellExplored == false) { cellExplored = (tc0->isExplored(thisTeamIndex) || tc1->isExplored(thisTeamIndex)); } - if(tc0->getNearSubmerged() && cellExplored == true) { + if(cellExplored == true && tc0->getNearSubmerged()) { glNormal3f(0.f, 1.f, 0.f); closed= false; @@ -4501,8 +4500,7 @@ void Renderer::renderWater() { } else{ - if(!closed){ - + if(closed == false) { pointCount+= 2; //vertex 1 @@ -6670,11 +6668,6 @@ Vec4f Renderer::computeMoonPos(float time) { #endif } -Vec4f Renderer::computeWaterColor(float waterLevel, float cellHeight) { - const float waterFactor= 1.5f; - return Vec4f(1.f, 1.f, 1.f, clamp((waterLevel-cellHeight)*waterFactor, 0.f, 1.f)); -} - // ==================== fast render ==================== //render units for selection purposes diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index 42cba092..c496deb7 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -597,7 +597,10 @@ private: float computeMoonAngle(float time); Vec4f computeSunPos(float time); Vec4f computeMoonPos(float time); - Vec4f computeWaterColor(float waterLevel, float cellHeight); + inline Vec4f computeWaterColor(float waterLevel, float cellHeight) { + const float waterFactor= 1.5f; + return Vec4f(1.f, 1.f, 1.f, clamp((waterLevel-cellHeight) * waterFactor, 0.f, 1.f)); + } void checkExtension(const string &extension, const string &msg); //selection render