summaryrefslogtreecommitdiffhomepage
path: root/editor/draw.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-10-23 04:40:15 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-10-23 04:40:15 +0200
commit630e16296276eacec4fea22519b8610b88847a1a (patch)
tree61de3c427a459cd6d303b4c4654edf25e1e85575 /editor/draw.cpp
parent264c759ce2cdc53df28248394f40400d6dcf9ace (diff)
fix snap-drag tile display
Diffstat (limited to 'editor/draw.cpp')
-rw-r--r--editor/draw.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/editor/draw.cpp b/editor/draw.cpp
index f482d373..09f9c490 100644
--- a/editor/draw.cpp
+++ b/editor/draw.cpp
@@ -25,9 +25,17 @@ void app::draw_cursor()
auto& w = M->world();
const auto inactive_color = 0xff00ffff_rgbaf;
- if (cursor.tile && !cursor.in_imgui)
+ global_coords tile;
+ if (auto pos = _editor.mouse_drag_pos())
+ tile = *pos;
+ else if (cursor.tile)
+ tile = *cursor.tile;
+ else
+ return;
+
+ if (!cursor.in_imgui)
{
- const auto draw = [&, pos = *cursor.tile](auto& mesh, const auto& size) {
+ const auto draw = [&, pos = tile](auto& mesh, const auto& size) {
const auto center = Vector3(pos) * TILE_SIZE;
mesh.draw(shader, {center, size, LINE_WIDTH});
};
@@ -58,9 +66,9 @@ void app::draw_cursor()
shader.set_tint({1, 1, 1, 0.75f});
auto [_f, _w, anim_mesh] = M->meshes();
const auto offset = Vector3i(Vector2i(sel.offset), 0);
- const auto pos = Vector3i(*cursor.tile)*iTILE_SIZE + offset;
- auto [ch, t] = w[*cursor.tile];
- if (!ch.can_place_object(sel, cursor.tile->local()))
+ const auto pos = Vector3i(tile)*iTILE_SIZE + offset;
+ auto [ch, t] = w[tile];
+ if (!ch.can_place_object(sel, tile.local()))
shader.set_tint({1, 0, 1, 0.5f});
anim_mesh.draw(shader, *sel.atlas, sel.r, sel.frame, Vector3(pos), 1);
}
@@ -75,7 +83,7 @@ void app::draw_cursor()
draw(_wireframe_quad, TILE_SIZE2);
shader.set_tint({1, 1, 1, 0.75f});
auto [_f, _w, anim_mesh] = M->meshes();
- const auto pos = Vector3i(*cursor.tile)*iTILE_SIZE;
+ const auto pos = Vector3i(tile)*iTILE_SIZE;
anim_mesh.draw(shader, *atlas, rotation::N, 0, Vector3(pos), 1);
}
}