summaryrefslogtreecommitdiffhomepage
path: root/editor/camera.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-01 18:01:03 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-01 18:01:03 +0100
commit92585b90be4b0be8953618d68f866711c9d15c7a (patch)
tree219f6742b9fb5bcd8411290cb14b24fd5e61a749 /editor/camera.cpp
parent595081292307808fcd5140ae92594efea899d5dc (diff)
w
Diffstat (limited to 'editor/camera.cpp')
-rw-r--r--editor/camera.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/editor/camera.cpp b/editor/camera.cpp
index 3ec532eb..696c5348 100644
--- a/editor/camera.cpp
+++ b/editor/camera.cpp
@@ -158,4 +158,15 @@ void app::update_cursor_tile(const Optional<Vector2i>& pixel)
}
}
+Vector2 app::point_screen_pos(point pt)
+{
+ auto& shader = M->shader();
+ auto win_size = M->window_size();
+ auto c3 = pt.chunk3();
+ auto c2 = pt.chunk();
+ with_shifted_camera_offset co{shader, c3, c2, c2 };
+ auto world_pos = TILE_SIZE20 * Vector3(pt.local()) + Vector3(Vector2(pt.offset()), 0);
+ return Vector2(shader.camera_offset()) + Vector2(win_size)*.5f + shader.project(world_pos);
+}
+
} // namespace floormat