diff --git a/include/omath/projection/camera.hpp b/include/omath/projection/camera.hpp index f5c66b6..30da354 100644 --- a/include/omath/projection/camera.hpp +++ b/include/omath/projection/camera.hpp @@ -107,7 +107,8 @@ namespace omath::projection // m[1,1] == 1 / tan(fov/2) => fov = 2 * atan(1 / m[1,1]) const auto f = proj_matrix.at(1, 1); // m[0,0] == m[1,1] / aspect_ratio => aspect = m[1,1] / m[0,0] - return {FieldOfView::from_radians(NumericType{2} * std::atan(NumericType{1} / f)), + const auto fov_radians = NumericType{2} * std::atan(NumericType{1} / f); + return {FieldOfView::from_radians(static_cast(fov_radians)), f / proj_matrix.at(0, 0)}; } diff --git a/source/lua/lua_hud.cpp b/source/lua/lua_hud.cpp index 6529496..3a79024 100644 --- a/source/lua/lua_hud.cpp +++ b/source/lua/lua_hud.cpp @@ -14,6 +14,13 @@ namespace { + [[noreturn]] + void throw_lua_error(sol::protected_function_result& result) + { + sol::error err = result; + throw err; + } + class LuaHudRenderer final : public omath::hud::HudRendererInterface { public: @@ -82,7 +89,7 @@ namespace auto result = (*callback)(texture, min, max, tint); if (!result.valid()) - throw sol::error(result); + throw_lua_error(result); } void add_text(const omath::Vector2& position, const omath::Color& color, @@ -100,7 +107,7 @@ namespace auto result = (*callback)(std::string{text}); if (!result.valid()) - throw sol::error(result); + throw_lua_error(result); return result.get>(); } @@ -126,7 +133,7 @@ namespace auto result = (*callback)(std::forward(args)...); if (!result.valid()) - throw sol::error(result); + throw_lua_error(result); } [[nodiscard]]