Merge HalfDiamond into Diamond, store ctor parameters.
Also added unit test.
This commit is contained in:
parent
ad127b8fbe
commit
e8584d87fa
4 changed files with 53 additions and 34 deletions
|
@ -2,30 +2,33 @@
|
|||
|
||||
namespace dk {
|
||||
PixelConvDiamond::PixelConvDiamond (bool parStaggered, bool parFirstReentrant) :
|
||||
base_class(parStaggered ? MapType_IsometricStaggered : MapType_Isometric)
|
||||
base_class(parStaggered ? MapType_IsometricStaggered : MapType_Isometric),
|
||||
m_ratio(1),
|
||||
m_first_reentr(parFirstReentrant ? 1 : 0),
|
||||
m_staggered(parStaggered)
|
||||
{
|
||||
}
|
||||
|
||||
PixelConvDiamond::PixelConvDiamond (MapTypes parType, bool parStaggered, bool parFirstReentrant) :
|
||||
base_class(MapType_IsometricStaggered)
|
||||
PixelConvDiamond::PixelConvDiamond (bool parStaggered, bool parFirstReentrant, const coords& parRatio) :
|
||||
base_class(MapType_IsometricStaggered),
|
||||
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& parSize) const -> coords {
|
||||
const auto from(parFrom);
|
||||
const CoordinateScalarType xoffs = from.y() % 2;
|
||||
if (m_staggered) {
|
||||
const auto from(parFrom);
|
||||
const CoordinateScalarType xoffs = m_first_reentr xor (from.y() bitand 1);
|
||||
|
||||
return from * parSize + coords(xoffs * parSize.x() / 2, 0);
|
||||
}
|
||||
|
||||
PixelConvHalfDiamond::PixelConvHalfDiamond (bool parHalfVertically) :
|
||||
base_class(MapType_IsometricStaggered, true, true),
|
||||
m_div(parHalfVertically ? coords(1, 2) : coords(2, 1))
|
||||
{
|
||||
}
|
||||
|
||||
auto PixelConvHalfDiamond::to_pixel (const coords& parFrom, const coords& parSize) const -> coords {
|
||||
return base_class::to_pixel(parFrom, parSize / m_div);
|
||||
return (from * parSize + coords(xoffs * parSize.x() / 2, 0)) / m_ratio;
|
||||
}
|
||||
else {
|
||||
DK_ASSERT(false); //not implemented
|
||||
return coords(0);
|
||||
}
|
||||
}
|
||||
|
||||
PixelConvHex::PixelConvHex (bool parFirstReentrant) :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue