mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-15 00:05:02 +02:00
Fix graphical artifacts on map scaling
This commit is contained in:
@ -108,8 +108,9 @@ void MapViewCache::updateTile(const std::shared_ptr<IMapRendererContext> & conte
|
|||||||
void MapViewCache::update(const std::shared_ptr<IMapRendererContext> & context)
|
void MapViewCache::update(const std::shared_ptr<IMapRendererContext> & context)
|
||||||
{
|
{
|
||||||
Rect dimensions = model->getTilesTotalRect();
|
Rect dimensions = model->getTilesTotalRect();
|
||||||
|
bool mapResized = cachedSize != model->getSingleTileSize();
|
||||||
|
|
||||||
if(dimensions.w != terrainChecksum.shape()[0] || dimensions.h != terrainChecksum.shape()[1])
|
if(mapResized || dimensions.w != terrainChecksum.shape()[0] || dimensions.h != terrainChecksum.shape()[1])
|
||||||
{
|
{
|
||||||
boost::multi_array<TileChecksum, 2> newCache;
|
boost::multi_array<TileChecksum, 2> newCache;
|
||||||
newCache.resize(boost::extents[dimensions.w][dimensions.h]);
|
newCache.resize(boost::extents[dimensions.w][dimensions.h]);
|
||||||
@ -117,7 +118,7 @@ void MapViewCache::update(const std::shared_ptr<IMapRendererContext> & context)
|
|||||||
terrainChecksum = newCache;
|
terrainChecksum = newCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dimensions.w != tilesUpToDate.shape()[0] || dimensions.h != tilesUpToDate.shape()[1])
|
if(mapResized || dimensions.w != tilesUpToDate.shape()[0] || dimensions.h != tilesUpToDate.shape()[1])
|
||||||
{
|
{
|
||||||
boost::multi_array<bool, 2> newCache;
|
boost::multi_array<bool, 2> newCache;
|
||||||
newCache.resize(boost::extents[dimensions.w][dimensions.h]);
|
newCache.resize(boost::extents[dimensions.w][dimensions.h]);
|
||||||
@ -129,6 +130,7 @@ void MapViewCache::update(const std::shared_ptr<IMapRendererContext> & context)
|
|||||||
for(int x = dimensions.left(); x < dimensions.right(); ++x)
|
for(int x = dimensions.left(); x < dimensions.right(); ++x)
|
||||||
updateTile(context, {x, y, model->getLevel()});
|
updateTile(context, {x, y, model->getLevel()});
|
||||||
|
|
||||||
|
cachedSize = model->getSingleTileSize();
|
||||||
cachedLevel = model->getLevel();
|
cachedLevel = model->getLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ class MapViewCache
|
|||||||
boost::multi_array<TileChecksum, 2> terrainChecksum;
|
boost::multi_array<TileChecksum, 2> terrainChecksum;
|
||||||
boost::multi_array<bool, 2> tilesUpToDate;
|
boost::multi_array<bool, 2> tilesUpToDate;
|
||||||
|
|
||||||
|
Point cachedSize;
|
||||||
Point cachedPosition;
|
Point cachedPosition;
|
||||||
int cachedLevel;
|
int cachedLevel;
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@ void MapViewModel::setLevel(int newLevel)
|
|||||||
Point MapViewModel::getSingleTileSizeUpperLimit() const
|
Point MapViewModel::getSingleTileSizeUpperLimit() const
|
||||||
{
|
{
|
||||||
// arbitrary-seleted upscaling limit
|
// arbitrary-seleted upscaling limit
|
||||||
// TODO: figure out reason behind graphical artifacts on scaling higher than 120px (375%)
|
return Point(256, 256);
|
||||||
return Point(120, 120);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Point MapViewModel::getSingleTileSizeLowerLimit() const
|
Point MapViewModel::getSingleTileSizeLowerLimit() const
|
||||||
|
Reference in New Issue
Block a user