diff --git a/include/doorkeeper/components/pixelconv.hpp b/include/doorkeeper/components/pixelconv.hpp index 5851db7..6c63c02 100644 --- a/include/doorkeeper/components/pixelconv.hpp +++ b/include/doorkeeper/components/pixelconv.hpp @@ -35,6 +35,8 @@ namespace dk { PixelConv ( MapTypes parType, const coords& parTileSize ); virtual coords to_pixel ( const coords& parFrom ) const = 0; + virtual coords pick_tile ( const coords& parPixelPoint ) const = 0; + MapTypes map_type ( void ) const; const coords& tile_size ( void ) const; @@ -53,6 +55,7 @@ namespace dk { virtual ~PixelConvSquare ( void ) noexcept = default; virtual coords to_pixel ( const coords& parFrom ) const; + virtual coords pick_tile ( const coords& parPixelPoint ) const; }; class PixelConvDiamond : public PixelConv<2> { @@ -65,6 +68,7 @@ namespace dk { virtual ~PixelConvDiamond ( void ) noexcept = default; virtual coords to_pixel ( const coords& parFrom ) const; + virtual coords pick_tile ( const coords& parPixelPoint ) const; protected: const coords m_ratio; @@ -81,6 +85,10 @@ namespace dk { virtual ~PixelConvHex ( void ) noexcept = default; virtual coords to_pixel ( const coords& parFrom ) const; + virtual coords pick_tile ( const coords& parPixelPoint ) const; + + private: + const CoordinateScalarType m_first_reentr; }; template diff --git a/include/doorkeeper/implem/pixelconv.inl b/include/doorkeeper/implem/pixelconv.inl index 960dd53..0093d13 100644 --- a/include/doorkeeper/implem/pixelconv.inl +++ b/include/doorkeeper/implem/pixelconv.inl @@ -71,4 +71,9 @@ namespace dk { auto PixelConvSquare::to_pixel (const coords& parFrom) const -> coords { return parFrom * this->tile_size(); } + + template + auto PixelConvSquare::pick_tile (const coords& parPixelPoint) const -> coords { + return parPixelPoint / this->tile_size(); + } } //namespace dk diff --git a/src/pixelconv.cpp b/src/pixelconv.cpp index b82cee2..80fbe5d 100644 --- a/src/pixelconv.cpp +++ b/src/pixelconv.cpp @@ -49,8 +49,14 @@ namespace dk { } } + auto PixelConvDiamond::pick_tile (const coords& parPixelPoint) const -> coords { + DK_ASSERT(false); //not implemented + return coords(0); + } + PixelConvHex::PixelConvHex (const coords& parTileSize, bool parFirstReentrant) : - base_class(MapType_Hex, parTileSize) + base_class(MapType_Hex, parTileSize), + m_first_reentr(parFirstReentrant ? 1 : 0) { } @@ -58,4 +64,9 @@ namespace dk { DK_ASSERT(false); //not implemented return coords(0); } + + auto PixelConvHex::pick_tile (const coords& parPixelPoint) const -> coords { + DK_ASSERT(false); //not implemented + return coords(0); + } } //namespace dk