summaryrefslogtreecommitdiffhomepage
path: root/editor/draw.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-08 12:01:42 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-08 12:21:26 +0200
commit0cd263af59f256da2d2f3a77be264d5e64c1ec5d (patch)
treef89935707693657ac804aef27c6b188ed66f4d30 /editor/draw.cpp
parentd1984938e4f0cbc24b7b8cc6e219fa873d39418a (diff)
mplement z levels
Diffstat (limited to 'editor/draw.cpp')
-rw-r--r--editor/draw.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/editor/draw.cpp b/editor/draw.cpp
index adbc7b60..c01c149d 100644
--- a/editor/draw.cpp
+++ b/editor/draw.cpp
@@ -72,12 +72,13 @@ void app::draw_collision_boxes()
auto& world = M->world();
auto& shader = M->shader();
- shader.set_tint({0, .5f, 1, 1});
-
using rtree_type = std::decay_t<decltype(*world[chunk_coords{}].rtree())>;
using rect_type = typename rtree_type::Rect;
for (int8_t z = z_min; z <= z_max; z++)
+ {
+ shader.set_tint({0, .5f, 1, 1});
+
for (int16_t y = miny; y <= maxy; y++)
for (int16_t x = minx; x <= maxx; x++)
{
@@ -103,19 +104,18 @@ void app::draw_collision_boxes()
}
}
- shader.set_tint({1, 0, 1, 1});
+ shader.set_tint({1, 0, 1, 1});
- if (cursor.tile)
- {
- constexpr auto eps = 1e-6f;
- constexpr auto m = TILE_SIZE2 * Vector2(1- eps, 1- eps);
- const auto tile_ = Vector2(M->pixel_to_tile_(Vector2d(*cursor.pixel)));
- const auto tile = *cursor.tile;
- const auto curchunk = Vector2(tile.chunk()), curtile = Vector2(tile.local());
- const auto subpixel_ = Vector2(std::fmod(tile_[0], 1.f), std::fmod(tile_[1], 1.f));
- const auto subpixel = m * Vector2(curchunk[0] < 0 ? 1 + subpixel_[0] : subpixel_[0],
- curchunk[1] < 0 ? 1 + subpixel_[1] : subpixel_[1]);
- for (int8_t z = z_min; z <= z_max; z++)
+ if (cursor.tile)
+ {
+ constexpr auto eps = 1e-6f;
+ constexpr auto m = TILE_SIZE2 * Vector2(1- eps, 1- eps);
+ const auto tile_ = Vector2(M->pixel_to_tile_(Vector2d(*cursor.pixel)));
+ const auto tile = *cursor.tile;
+ const auto curchunk = Vector2(tile.chunk()), curtile = Vector2(tile.local());
+ const auto subpixel_ = Vector2(std::fmod(tile_[0], 1.f), std::fmod(tile_[1], 1.f));
+ const auto subpixel = m * Vector2(curchunk[0] < 0 ? 1 + subpixel_[0] : subpixel_[0],
+ curchunk[1] < 0 ? 1 + subpixel_[1] : subpixel_[1]);
for (int16_t y = miny; y <= maxy; y++)
for (int16_t x = minx; x <= maxx; x++)
{
@@ -144,6 +144,7 @@ void app::draw_collision_boxes()
});
}
}
+ }
}
shader.set_tint({1, 1, 1, 1});