Enable overlays other than the pathfinding one when the pathfinding one is hidden.
This was SVN commit r5496.
This commit is contained in:
parent
c984d8a107
commit
f304a4debe
@ -43,7 +43,7 @@ bool g_VSync = false;
|
||||
bool g_Quickstart = false;
|
||||
|
||||
// flag to switch on drawing terrain overlays
|
||||
bool g_ShowOverlay = false;
|
||||
bool g_ShowPathfindingOverlay = false;
|
||||
|
||||
// flag to switch on triangulation pathfinding
|
||||
bool g_TriPathfind = false;
|
||||
@ -166,7 +166,7 @@ static void ProcessCommandLineArgs(const CmdLineArgs& args)
|
||||
g_ConfigDB.CreateValue(CFG_COMMAND, "vsync")->m_String = "true";
|
||||
|
||||
if (args.Has("showOverlay"))
|
||||
g_ShowOverlay = true;
|
||||
g_ShowPathfindingOverlay = true;
|
||||
|
||||
if (args.Has("triPathfind"))
|
||||
g_TriPathfind = true;
|
||||
|
@ -53,6 +53,6 @@ extern CStr g_CursorName;
|
||||
class CmdLineArgs;
|
||||
extern void CONFIG_Init(const CmdLineArgs& args);
|
||||
|
||||
extern bool g_ShowOverlay;
|
||||
extern bool g_ShowPathfindingOverlay;
|
||||
|
||||
extern bool g_TriPathfind;
|
||||
|
@ -214,24 +214,21 @@ void TerrainOverlay::GetTileExtents(
|
||||
|
||||
void TerrainOverlay::Render()
|
||||
{
|
||||
if(g_ShowOverlay)
|
||||
{
|
||||
m_Terrain = g_Game->GetWorld()->GetTerrain();
|
||||
m_Terrain = g_Game->GetWorld()->GetTerrain();
|
||||
|
||||
int min_i, min_j, max_i, max_j;
|
||||
GetTileExtents(min_i, min_j, max_i, max_j);
|
||||
// Clamp the min to 0, but the max to -1 - so tile -1 can never be rendered,
|
||||
// but if unclamped_max<0 then no tiles at all will be rendered. And the same
|
||||
// for the upper limit.
|
||||
min_i = clamp(min_i, 0, (int)m_Terrain->GetTilesPerSide());
|
||||
min_j = clamp(min_j, 0, (int)m_Terrain->GetTilesPerSide());
|
||||
max_i = clamp(max_i, -1, (int)m_Terrain->GetTilesPerSide()-1);
|
||||
max_j = clamp(max_j, -1, (int)m_Terrain->GetTilesPerSide()-1);
|
||||
int min_i, min_j, max_i, max_j;
|
||||
GetTileExtents(min_i, min_j, max_i, max_j);
|
||||
// Clamp the min to 0, but the max to -1 - so tile -1 can never be rendered,
|
||||
// but if unclamped_max<0 then no tiles at all will be rendered. And the same
|
||||
// for the upper limit.
|
||||
min_i = clamp(min_i, 0, (int)m_Terrain->GetTilesPerSide());
|
||||
min_j = clamp(min_j, 0, (int)m_Terrain->GetTilesPerSide());
|
||||
max_i = clamp(max_i, -1, (int)m_Terrain->GetTilesPerSide()-1);
|
||||
max_j = clamp(max_j, -1, (int)m_Terrain->GetTilesPerSide()-1);
|
||||
|
||||
for (m_j = min_j; m_j <= max_j; ++m_j)
|
||||
for (m_i = min_i; m_i <= max_i; ++m_i)
|
||||
ProcessTile(m_i, m_j);
|
||||
}
|
||||
for (m_j = min_j; m_j <= max_j; ++m_j)
|
||||
for (m_i = min_i; m_i <= max_i; ++m_i)
|
||||
ProcessTile(m_i, m_j);
|
||||
}
|
||||
|
||||
void TerrainOverlay::RenderTile(const CColor& colour, bool draw_hidden)
|
||||
|
@ -227,7 +227,7 @@ bool CAStarEngine::FindPath(
|
||||
//it's guarded here to stop setting the drawing path in pathfindingOverlay.
|
||||
//(efficiency issue)
|
||||
//the drawing is disable in the render() function in TerraiOverlay.cpp
|
||||
if(g_ShowOverlay)
|
||||
if(g_ShowPathfindingOverlay)
|
||||
{
|
||||
pathfindingOverlay.setPath(mPath);
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ void CEntity::removeObstacle()
|
||||
g_Pathfinder.dcdtPathfinder.DeleteAbstraction();
|
||||
g_Pathfinder.dcdtPathfinder.Abstract();
|
||||
|
||||
if(g_ShowOverlay)
|
||||
if(g_ShowPathfindingOverlay)
|
||||
{
|
||||
g_Pathfinder.drawTriangulation();
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ void CEntityManager::updateObstacle( CEntity* tempHandle )
|
||||
g_Pathfinder.dcdtPathfinder.DeleteAbstraction();
|
||||
g_Pathfinder.dcdtPathfinder.Abstract();
|
||||
|
||||
if(g_ShowOverlay)
|
||||
if(g_ShowPathfindingOverlay)
|
||||
{
|
||||
g_Pathfinder.drawTriangulation();
|
||||
}
|
||||
|
@ -19,13 +19,25 @@
|
||||
|
||||
|
||||
|
||||
CPathfindEngine::CPathfindEngine():OABBBOUNDREDUCTION(0.8),CIRCLEBOUNDREDUCTION(0.5),RADIUSINCREMENT(2.0)
|
||||
CPathfindEngine::CPathfindEngine() : triangulationOverlay(0),
|
||||
OABBBOUNDREDUCTION(0.8),
|
||||
CIRCLEBOUNDREDUCTION(0.5),
|
||||
RADIUSINCREMENT(2.0)
|
||||
{
|
||||
dcdtInitialized = false;
|
||||
|
||||
|
||||
if (g_ShowPathfindingOverlay)
|
||||
triangulationOverlay = new TriangulationTerrainOverlay();
|
||||
}
|
||||
|
||||
CPathfindEngine::~CPathfindEngine()
|
||||
{
|
||||
if (triangulationOverlay)
|
||||
{
|
||||
delete triangulationOverlay;
|
||||
triangulationOverlay = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Todo:
|
||||
// 1; the bouncing problem with the fortress
|
||||
@ -169,9 +181,11 @@ void CPathfindEngine::drawTriangulation()
|
||||
|
||||
dcdtPathfinder.get_mesh_edges(&constrainedEdges, &unconstrainedEdges);
|
||||
|
||||
triangulationOverlay.setConstrainedEdges(constrainedEdges);
|
||||
triangulationOverlay.setUnconstrainedEdges(unconstrainedEdges);
|
||||
|
||||
if (triangulationOverlay)
|
||||
{
|
||||
triangulationOverlay->setConstrainedEdges(constrainedEdges);
|
||||
triangulationOverlay->setUnconstrainedEdges(unconstrainedEdges);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -220,10 +234,10 @@ void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D&
|
||||
|
||||
|
||||
//switch on/off triangulation drawing by command line arg "-showOverlay"
|
||||
//it's guarded here to stop setting constrainedEdges and unconstrainedEdges in triangulationOverlay.
|
||||
//it's guarded here to stop setting constrainedEdges and unconstrainedEdges in triangulationOverlay->
|
||||
//(efficiency issue)
|
||||
//the drawing is disable in the render() function in TerraiOverlay.cpp
|
||||
if(g_ShowOverlay)
|
||||
if(g_ShowPathfindingOverlay)
|
||||
{
|
||||
drawTriangulation();
|
||||
}
|
||||
@ -264,7 +278,10 @@ void CPathfindEngine::RequestTriangulationPath( HEntity entity, const CVector2D&
|
||||
|
||||
|
||||
//set and draw the path on the terrain
|
||||
triangulationOverlay.setCurrentPath(CurPath);
|
||||
if (triangulationOverlay)
|
||||
{
|
||||
triangulationOverlay->setCurrentPath(CurPath);
|
||||
}
|
||||
|
||||
// Make the path take as few steps as possible by collapsing steps in the same direction together.
|
||||
std::vector<CVector2D> path;
|
||||
|
@ -51,10 +51,11 @@ public:
|
||||
void drawTriangulation();
|
||||
|
||||
//Kai:added tile overlay for pathfinding
|
||||
TriangulationTerrainOverlay triangulationOverlay;
|
||||
TriangulationTerrainOverlay* triangulationOverlay;
|
||||
|
||||
|
||||
CPathfindEngine();
|
||||
~CPathfindEngine();
|
||||
|
||||
void RequestPath( HEntity entity, const CVector2D& destination,
|
||||
CEntityOrder::EOrderSource orderSource );
|
||||
|
Loading…
Reference in New Issue
Block a user