diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-22 03:56:58 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-22 03:56:58 +0100 |
commit | 9e749583791c9523efab90665ffd8f5c30e4f449 (patch) | |
tree | bcb7fd1774e0b1ca4f69ff19c9c2f9e3c63eac1a /src/tile-atlas.hpp | |
parent | 34c451c6b64ba1c11efa9a390c16e2097a25279a (diff) |
a wip
Diffstat (limited to 'src/tile-atlas.hpp')
-rw-r--r-- | src/tile-atlas.hpp | 46 |
1 files changed, 1 insertions, 45 deletions
diff --git a/src/tile-atlas.hpp b/src/tile-atlas.hpp index 26d3fc17..205da68f 100644 --- a/src/tile-atlas.hpp +++ b/src/tile-atlas.hpp @@ -17,12 +17,8 @@ struct tile_atlas final tile_atlas(StringView path, StringView name, const ImageView2D& img, Vector2ub tile_count, Optional<enum pass_mode> pass_mode); - static texcoords texcoords_at(Vector2ui pos, Vector2ui size, Vector2ui image_size); texcoords texcoords_for_id(size_t id) const; - static constexpr quad floor_quad(Vector3 center, Vector2 size); - static constexpr quad wall_quad_N(Vector3 center, Vector3 size); - static constexpr quad wall_quad_W(Vector3 center, Vector3 size); - static constexpr std::array<UnsignedShort, 6> indices(size_t N); + [[maybe_unused]] Vector2ui pixel_size() const { return size_; } size_t num_tiles() const; Vector2ub num_tiles2() const { return dims_; } @@ -44,46 +40,6 @@ private: Optional<enum pass_mode> passability; }; -constexpr std::array<UnsignedShort, 6> tile_atlas::indices(size_t N) -{ - using u16 = UnsignedShort; - return { /* 3--1 1 */ - (u16)(0+N*4), (u16)(1+N*4), (u16)(2+N*4), /* | / /| */ - (u16)(2+N*4), (u16)(1+N*4), (u16)(3+N*4), /* |/ / | */ - }; /* 2 2--0 */ -} - -constexpr tile_atlas::quad tile_atlas::floor_quad(const Vector3 center, const Vector2 size) -{ - float x = size[0]*.5f, y = size[1]*.5f; - return {{ - { x + center[0], -y + center[1], center[2]}, - { x + center[0], y + center[1], center[2]}, - {-x + center[0], -y + center[1], center[2]}, - {-x + center[0], y + center[1], center[2]}, - }}; -} -constexpr tile_atlas::quad tile_atlas::wall_quad_W(const Vector3 center, const Vector3 size) -{ - float x = size[0]*.5f, y = size[1]*.5f, z = size[2]; - return {{ - {-x + center[0], y + center[1], z + center[2] }, - {-x + center[0], y + center[1], center[2] }, - {-x + center[0], -y + center[1], z + center[2] }, - {-x + center[0], -y + center[1], center[2] }, - }}; -} - -constexpr tile_atlas::quad tile_atlas::wall_quad_N(const Vector3 center, const Vector3 size) -{ - float x = size[0]*.5f, y = size[1]*.5f, z = size[2]; - return {{ - { x + center[0], -y + center[1], z + center[2] }, - { x + center[0], -y + center[1], center[2] }, - {-x + center[0], -y + center[1], z + center[2] }, - {-x + center[0], -y + center[1], center[2] }, - }}; -} } // namespace floormat |