DoorKeeper/src/pixelconv.cpp

45 lines
1.3 KiB
C++
Raw Normal View History

#include "doorkeeper/components/pixelconv.hpp"
namespace dk {
PixelConvDiamond::PixelConvDiamond (const coords& parTileSize, bool parStaggered, bool parFirstReentrant) :
base_class(parStaggered ? MapType_IsometricStaggered : MapType_Isometric, parTileSize),
m_ratio(1),
m_first_reentr(parFirstReentrant ? 1 : 0),
m_staggered(parStaggered)
{
}
PixelConvDiamond::PixelConvDiamond (const coords& parTileSize, bool parStaggered, bool parFirstReentrant, const coords& parRatio) :
base_class(MapType_IsometricStaggered, parTileSize),
m_ratio(parRatio),
m_first_reentr(parFirstReentrant ? 1 : 0),
m_staggered(parStaggered)
{
DK_ASSERT(parRatio > 0);
}
auto PixelConvDiamond::to_pixel (const coords& parFrom) const -> coords {
if (m_staggered) {
const auto from(parFrom);
const CoordinateScalarType xoffs = m_first_reentr xor (from.y() bitand 1);
const auto& tile_size = this->tile_size();
return (from * tile_size + coords(xoffs * tile_size.x() / 2, 0)) / m_ratio;
}
else {
DK_ASSERT(false); //not implemented
return coords(0);
}
}
PixelConvHex::PixelConvHex (const coords& parTileSize, bool parFirstReentrant) :
base_class(MapType_Hex, parTileSize)
{
}
auto PixelConvHex::to_pixel (const coords& parFrom) const -> coords {
DK_ASSERT(false); //not implemented
return coords(0);
}
} //namespace dk