diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-29 18:59:39 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-29 18:59:39 +0200 |
| commit | d9cf49f11a5767fab52994e5c38d58ba16b13af6 (patch) | |
| tree | 0d9adf6eb81bc75f0c1aaf616efe554ff6c64b56 /draw | |
| parent | d309ed0b2ac06d7ba48322303d56bf39c8b57fe4 (diff) | |
use vectors without open-coding vector ops
Suggested by mosra.
Diffstat (limited to 'draw')
| -rw-r--r-- | draw/floor.cpp | 10 | ||||
| -rw-r--r-- | draw/wall.cpp | 8 |
2 files changed, 6 insertions, 12 deletions
diff --git a/draw/floor.cpp b/draw/floor.cpp index bfba0c00..444ee127 100644 --- a/draw/floor.cpp +++ b/draw/floor.cpp @@ -74,13 +74,9 @@ std::array<std::array<UnsignedShort, 6>, TILE_COUNT> floor_mesh::make_index_arra std::array<std::array<Vector3, 4>, TILE_COUNT> floor_mesh::make_position_array() { std::array<std::array<Vector3, 4>, TILE_COUNT> array; - constexpr float X = TILE_SIZE[0], Y = TILE_SIZE[1]; - for (std::size_t j = 0, k = 0; j < TILE_MAX_DIM; j++) - for (std::size_t i = 0; i < TILE_MAX_DIM; i++, k++) - { - Vector3 center {(float)(X*i), (float)(Y*j), 0}; - array[k] = { tile_atlas::floor_quad(center, {X, Y}) }; - } + for (std::uint8_t j = 0, k = 0; j < TILE_MAX_DIM; j++) + for (std::uint8_t i = 0; i < TILE_MAX_DIM; i++, k++) + array[k] = { tile_atlas::floor_quad(Vector3(i, j, 0) * TILE_SIZE, TILE_SIZE2) }; return array; } diff --git a/draw/wall.cpp b/draw/wall.cpp index ff3969fd..ae2e848c 100644 --- a/draw/wall.cpp +++ b/draw/wall.cpp @@ -78,15 +78,13 @@ std::array<std::array<UnsignedShort, 6>, wall_mesh::COUNT> wall_mesh::make_index std::array<std::array<Vector3, 4>, wall_mesh::COUNT> wall_mesh::make_position_array() { std::array<std::array<Vector3, 4>, COUNT> array; - constexpr float X = TILE_SIZE[0], Y = TILE_SIZE[1], Z = TILE_SIZE[2]; - constexpr Vector3 size = {X, Y, Z}; for (std::size_t j = 0; j < TILE_MAX_DIM; j++) for (std::size_t i = 0; i < TILE_MAX_DIM; i++) { const auto idx = (j*TILE_MAX_DIM + i) * 2; - Vector3 center{(float)(X*i), (float)(Y*j), 0}; - array[idx + 0] = tile_atlas::wall_quad_N(center, size); - array[idx + 1] = tile_atlas::wall_quad_W(center, size); + const auto center = Vector3((float)i, (float)j, 0) * TILE_SIZE; + array[idx + 0] = tile_atlas::wall_quad_N(center, TILE_SIZE); + array[idx + 1] = tile_atlas::wall_quad_W(center, TILE_SIZE); } return array; } |
