mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-23 16:40:08 +00:00
Check which local map textures actually need to be updated
On a typical exterior cell transition, we'll save 3 of 9 map renders. When moving back and forth between 2 cells, we can even reuse 6 of 9.
This commit is contained in:
parent
4d53ab6c32
commit
d1e86d22ca
2 changed files with 41 additions and 1 deletions
|
@ -231,13 +231,51 @@ void LocalMap::setupRenderToTexture(osg::ref_ptr<osg::Camera> camera, int x, int
|
||||||
segment.mMapTexture = texture;
|
segment.mMapTexture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool needUpdate(std::set<std::pair<int, int> >& renderedGrid, std::set<std::pair<int, int> >& currentGrid, int cellX, int cellY)
|
||||||
|
{
|
||||||
|
// if all the cells of the current grid are contained in the rendered grid then we can keep the old render
|
||||||
|
for (int dx=-1;dx<2;dx+=1)
|
||||||
|
{
|
||||||
|
for (int dy=-1;dy<2;dy+=1)
|
||||||
|
{
|
||||||
|
bool haveInRenderedGrid = renderedGrid.find(std::make_pair(cellX+dx,cellY+dy)) != renderedGrid.end();
|
||||||
|
bool haveInCurrentGrid = currentGrid.find(std::make_pair(cellX+dx,cellY+dy)) != currentGrid.end();
|
||||||
|
if (haveInCurrentGrid && !haveInRenderedGrid)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void LocalMap::requestMap(std::set<const MWWorld::CellStore*> cells)
|
void LocalMap::requestMap(std::set<const MWWorld::CellStore*> cells)
|
||||||
{
|
{
|
||||||
|
std::set<std::pair<int, int> > grid;
|
||||||
for (std::set<const MWWorld::CellStore*>::iterator it = cells.begin(); it != cells.end(); ++it)
|
for (std::set<const MWWorld::CellStore*>::iterator it = cells.begin(); it != cells.end(); ++it)
|
||||||
{
|
{
|
||||||
const MWWorld::CellStore* cell = *it;
|
const MWWorld::CellStore* cell = *it;
|
||||||
if (cell->isExterior())
|
if (cell->isExterior())
|
||||||
|
grid.insert(std::make_pair(cell->getCell()->getGridX(), cell->getCell()->getGridY()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (std::set<const MWWorld::CellStore*>::iterator it = cells.begin(); it != cells.end(); ++it)
|
||||||
|
{
|
||||||
|
const MWWorld::CellStore* cell = *it;
|
||||||
|
if (cell->isExterior())
|
||||||
|
{
|
||||||
|
int cellX = cell->getCell()->getGridX();
|
||||||
|
int cellY = cell->getCell()->getGridY();
|
||||||
|
|
||||||
|
MapSegment& segment = mSegments[std::make_pair(cellX, cellY)];
|
||||||
|
if (!needUpdate(segment.mGrid, grid, cellX, cellY))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
segment.mGrid = grid;
|
||||||
requestExteriorMap(cell);
|
requestExteriorMap(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
requestInteriorMap(cell);
|
requestInteriorMap(cell);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,8 @@ namespace MWRender
|
||||||
osg::ref_ptr<osg::Texture2D> mFogOfWarTexture;
|
osg::ref_ptr<osg::Texture2D> mFogOfWarTexture;
|
||||||
osg::ref_ptr<osg::Image> mFogOfWarImage;
|
osg::ref_ptr<osg::Image> mFogOfWarImage;
|
||||||
|
|
||||||
|
std::set<std::pair<int, int> > mGrid; // the grid that was active at the time of rendering this segment
|
||||||
|
|
||||||
bool mHasFogState;
|
bool mHasFogState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue