forked from 0ad/0ad
Improve speed of territory computation, fixes #2360
This was SVN commit r14530.
This commit is contained in:
parent
d0e57cb0ff
commit
7a3b1fe47e
@ -451,9 +451,7 @@ void CCmpTerritoryManager::CalculateTerritories()
|
||||
FloodFill(entityGrid, influenceGrid, openTiles, falloff);
|
||||
|
||||
// TODO: we should do a sparse grid and only add the non-zero regions, for performance
|
||||
for (u16 j = 0; j < entityGrid.m_H; ++j)
|
||||
for (u16 i = 0; i < entityGrid.m_W; ++i)
|
||||
playerGrid.set(i, j, playerGrid.get(i, j) + entityGrid.get(i, j));
|
||||
playerGrid.add(entityGrid);
|
||||
}
|
||||
|
||||
playerGrids.push_back(std::make_pair(it->first, playerGrid));
|
||||
|
@ -82,6 +82,17 @@ public:
|
||||
memset(m_Data, 0, m_W*m_H*sizeof(T));
|
||||
}
|
||||
|
||||
// Add two grids of the same size
|
||||
void add(const Grid& g)
|
||||
{
|
||||
#if GRID_BOUNDS_DEBUG
|
||||
ENSURE(g.m_W == m_W && g.m_H == m_H);
|
||||
#endif
|
||||
for (int j=0; j < m_H; ++j)
|
||||
for (int i=0; i < m_W; ++i)
|
||||
m_Data[j*m_W + i] += g.m_Data[j*m_W + i];
|
||||
}
|
||||
|
||||
void set(int i, int j, const T& value)
|
||||
{
|
||||
#if GRID_BOUNDS_DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user