- try to speed up water rendering a bit, but especially pathfinder
This commit is contained in:
parent
e2844938b7
commit
ef39f93457
|
@ -323,9 +323,9 @@ private:
|
||||||
std::map<Vec2i,Vec2i> cameFrom, std::map<std::pair<Vec2i,Vec2i> ,
|
std::map<Vec2i,Vec2i> cameFrom, std::map<std::pair<Vec2i,Vec2i> ,
|
||||||
bool> canAddNode, Unit *& unit, int & maxNodeCount, int curFrameIndex) {
|
bool> canAddNode, Unit *& unit, int & maxNodeCount, int curFrameIndex) {
|
||||||
|
|
||||||
Chrono chrono;
|
//Chrono chrono;
|
||||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
|
//if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
|
||||||
chrono.start();
|
//chrono.start();
|
||||||
|
|
||||||
FactionState &factionState = factions[unitFactionIndex];
|
FactionState &factionState = factions[unitFactionIndex];
|
||||||
while(nodeLimitReached == false) {
|
while(nodeLimitReached == false) {
|
||||||
|
@ -339,6 +339,24 @@ private:
|
||||||
pathFound = true;
|
pathFound = true;
|
||||||
break;
|
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) {
|
if(tryJPSPathfinder == true) {
|
||||||
closedNodes[node->pos] = 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(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));
|
//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));
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -4399,7 +4399,6 @@ void Renderer::renderWater() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool closed= false;
|
|
||||||
const World *world= game->getWorld();
|
const World *world= game->getWorld();
|
||||||
const Map *map= world->getMap();
|
const Map *map= world->getMap();
|
||||||
|
|
||||||
|
@ -4419,7 +4418,7 @@ void Renderer::renderWater() {
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
if(textures3D){
|
if(textures3D) {
|
||||||
Texture3D *waterTex= world->getTileset()->getWaterTex();
|
Texture3D *waterTex= world->getTileset()->getWaterTex();
|
||||||
if(waterTex == NULL) {
|
if(waterTex == NULL) {
|
||||||
throw megaglest_runtime_error("waterTex == NULL");
|
throw megaglest_runtime_error("waterTex == NULL");
|
||||||
|
@ -4444,6 +4443,10 @@ void Renderer::renderWater() {
|
||||||
|
|
||||||
assertGl();
|
assertGl();
|
||||||
|
|
||||||
|
int thisTeamIndex= world->getThisTeamIndex();
|
||||||
|
bool cellExplored = world->showWorldForPlayer(world->getThisFactionIndex());
|
||||||
|
bool closed= false;
|
||||||
|
|
||||||
Rect2i boundingRect= visibleQuad.computeBoundingRect();
|
Rect2i boundingRect= visibleQuad.computeBoundingRect();
|
||||||
Rect2i scaledRect= boundingRect/Map::cellScale;
|
Rect2i scaledRect= boundingRect/Map::cellScale;
|
||||||
scaledRect.clamp(0, 0, map->getSurfaceW()-1, map->getSurfaceH()-1);
|
scaledRect.clamp(0, 0, map->getSurfaceW()-1, map->getSurfaceH()-1);
|
||||||
|
@ -4453,7 +4456,6 @@ void Renderer::renderWater() {
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
|
|
||||||
for(int i=scaledRect.p[0].x; i<=scaledRect.p[1].x; ++i){
|
for(int i=scaledRect.p[0].x; i<=scaledRect.p[1].x; ++i){
|
||||||
|
|
||||||
SurfaceCell *tc0= map->getSurfaceCell(i, j);
|
SurfaceCell *tc0= map->getSurfaceCell(i, j);
|
||||||
SurfaceCell *tc1= map->getSurfaceCell(i, j+1);
|
SurfaceCell *tc1= map->getSurfaceCell(i, j+1);
|
||||||
if(tc0 == NULL) {
|
if(tc0 == NULL) {
|
||||||
|
@ -4463,14 +4465,11 @@ void Renderer::renderWater() {
|
||||||
throw megaglest_runtime_error("tc1 == NULL");
|
throw megaglest_runtime_error("tc1 == NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
int thisTeamIndex= world->getThisTeamIndex();
|
|
||||||
|
|
||||||
bool cellExplored = world->showWorldForPlayer(world->getThisFactionIndex());
|
|
||||||
if(cellExplored == false) {
|
if(cellExplored == false) {
|
||||||
cellExplored = (tc0->isExplored(thisTeamIndex) || tc1->isExplored(thisTeamIndex));
|
cellExplored = (tc0->isExplored(thisTeamIndex) || tc1->isExplored(thisTeamIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tc0->getNearSubmerged() && cellExplored == true) {
|
if(cellExplored == true && tc0->getNearSubmerged()) {
|
||||||
glNormal3f(0.f, 1.f, 0.f);
|
glNormal3f(0.f, 1.f, 0.f);
|
||||||
closed= false;
|
closed= false;
|
||||||
|
|
||||||
|
@ -4501,8 +4500,7 @@ void Renderer::renderWater() {
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(!closed){
|
if(closed == false) {
|
||||||
|
|
||||||
pointCount+= 2;
|
pointCount+= 2;
|
||||||
|
|
||||||
//vertex 1
|
//vertex 1
|
||||||
|
@ -6670,11 +6668,6 @@ Vec4f Renderer::computeMoonPos(float time) {
|
||||||
#endif
|
#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 ====================
|
// ==================== fast render ====================
|
||||||
|
|
||||||
//render units for selection purposes
|
//render units for selection purposes
|
||||||
|
|
|
@ -597,7 +597,10 @@ private:
|
||||||
float computeMoonAngle(float time);
|
float computeMoonAngle(float time);
|
||||||
Vec4f computeSunPos(float time);
|
Vec4f computeSunPos(float time);
|
||||||
Vec4f computeMoonPos(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);
|
void checkExtension(const string &extension, const string &msg);
|
||||||
|
|
||||||
//selection render
|
//selection render
|
||||||
|
|
Loading…
Reference in New Issue
Block a user