Skip to content

Commit

Permalink
uint32
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasaunai committed Nov 9, 2024
1 parent b47a9ad commit b11781c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/core/data/tiles/tile_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ class TileSetView
static auto constexpr dimension = Tile::dimension;

TileSetView(Box<int, dimension> const& box, std::array<std::size_t, dimension> const& tile_size,
std::array<int, dimension> const& shape, Tile** tiles, std::size_t tile_nbr,
int** cells, std::size_t nbr_cells)
std::array<std::uint32_t, dimension> const& shape, Tile* tiles,
std::uint32_t tile_nbr, Tile** cells,
std::array<std::uint32_t, dimension> const& nbr_cells)
: box_{box}
, tile_size_{tile_size}
, shape_{shape}
Expand All @@ -33,11 +34,13 @@ class TileSetView
private:
Box<int, dimension> const box_;
std::array<std::size_t, dimension> tile_size_;
std::array<int, dimension> shape_;
Span<Tile*> tiles_;
std::array<std::uint32_t, dimension> shape_;
Span<Tile> tiles_;
NdArrayView<dimension, Tile*> cells_;
};



template<typename Tile>
class TileSet
{
Expand All @@ -48,7 +51,7 @@ class TileSet
: box_{box}
, tile_size_{tile_size}
, shape_{[&]() {
std::array<int, dimension> s;
std::array<std::uint32_t, dimension> s;
auto bs = box.shape();
for (auto i = 0u; i < dimension; ++i)
{
Expand Down Expand Up @@ -102,8 +105,8 @@ class TileSet

auto make_view()
{
return TileSetView<Tile>{box_, tile_size_, shape_, tiles_.data(),
tiles_.size(), cells_.data(), cells_.size()};
return TileSetView<Tile>{box_, tile_size_, shape_, tiles_.data(),
tiles_.size(), cells_.data(), cells_.shape()};
}

private:
Expand Down Expand Up @@ -185,7 +188,7 @@ class TileSet

Box<int, dimension> box_;
std::array<std::size_t, dimension> tile_size_;
std::array<int, dimension> shape_;
std::array<std::uint32_t, dimension> shape_;
std::vector<Tile> tiles_;
NdArrayVector<dimension, Tile*> cells_;
};
Expand Down
6 changes: 6 additions & 0 deletions tests/core/data/tiles/test_tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ TYPED_TEST(TileTestBoxShapeNotMultipleTileSize, canRetrieveTileFromCell)
}


TYPED_TEST(TileTestBoxShapeNotMultipleTileSize, getView)
{
auto view = this->tileSet.make_view();
}



int main(int argc, char** argv)
{
Expand Down

0 comments on commit b11781c

Please sign in to comment.