DoorKeeper/include/implem/layer.inl

48 lines
2.1 KiB
Text
Raw Normal View History

namespace dk {
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <size_t D>
2014-12-12 19:04:48 +00:00
LayerBase<D>::LayerBase (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize) :
m_count(parCount / (parMasterTileSize / parTileSize)),
m_tilesize(parTileSize),
m_mastersize(parMasterTileSize)
{
DK_ASSERT((parMasterTileSize / parTileSize) * parTileSize == parMasterTileSize);
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, size_t D>
Layer<T, D>::Layer (const coords& parTileSize, const coords& parMasterTileSize, TileMapData<T, D>& parTilemap) :
LayerBase<D>(parTilemap.mapSize(), parTileSize, parMasterTileSize),
m_tilemap(parTilemap)
{
}
2014-12-12 19:04:48 +00:00
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, size_t D>
typename Layer<T, D>::iterator Layer<T, D>::begin() {
return iterator(&m_tiles, coords(0), this->m_count);
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, size_t D>
typename Layer<T, D>::iterator Layer<T, D>::end() {
return iterator(&m_tiles, implem::buildPastEndCoordinate<D>(coords(0), this->m_count), this->m_count);
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, size_t D>
void Layer<T, D>::preload (const coords& parFrom, const coords& parTo) {
2014-12-12 19:04:48 +00:00
m_tiles.clear();
std::cout << "Asking to fetch from " << parFrom << " to " << parTo << "\n";
const auto area = implem::area(parTo - parFrom);
2014-12-12 19:04:48 +00:00
m_tiles.reserve(area);
m_tilemap.fetch(m_tiles, parFrom, parTo);
//m_streamer->copy(m_tiles, parFrom, parTo);:w
2014-12-12 19:04:48 +00:00
}
}