From 8063c1697a5542c6ffa4fbbc4e202cfbe8b5aaba Mon Sep 17 00:00:00 2001 From: Orange Date: Sat, 21 Mar 2026 14:41:07 +0300 Subject: [PATCH] improved interface --- include/omath/projection/camera.hpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/include/omath/projection/camera.hpp b/include/omath/projection/camera.hpp index 013a947..f0b0a72 100644 --- a/include/omath/projection/camera.hpp +++ b/include/omath/projection/camera.hpp @@ -204,9 +204,25 @@ namespace omath::projection template [[nodiscard]] std::expected, Error> - world_to_screen(const Vector3& world_position, const bool auto_clip = true) const noexcept + world_to_screen(const Vector3& world_position) const noexcept { - const auto normalized_cords = world_to_view_port(world_position, auto_clip); + const auto normalized_cords = world_to_view_port(world_position); + + if (!normalized_cords.has_value()) + return std::unexpected{normalized_cords.error()}; + + if constexpr (screen_start == ScreenStart::TOP_LEFT_CORNER) + return ndc_to_screen_position_from_top_left_corner(*normalized_cords); + else if constexpr (screen_start == ScreenStart::BOTTOM_LEFT_CORNER) + return ndc_to_screen_position_from_bottom_left_corner(*normalized_cords); + else + std::unreachable(); + } + template + [[nodiscard]] std::expected, Error> + not_clip_world_to_screen(const Vector3& world_position) const noexcept + { + const auto normalized_cords = world_to_view_port(world_position, false); if (!normalized_cords.has_value()) return std::unexpected{normalized_cords.error()};