fixed for mingw

This commit is contained in:
2026-05-18 10:54:48 +03:00
parent 23d3b7c9f5
commit d9f2428e0e
+53 -50
View File
@@ -94,62 +94,65 @@ namespace
set_engine_aliases<PitchAngle, ViewAngles>(engine_table, types); set_engine_aliases<PitchAngle, ViewAngles>(engine_table, types);
engine_table.new_usertype<Camera>( auto camera_type = engine_table.new_usertype<Camera>(
"Camera", "Camera",
sol::constructors<Camera(const omath::Vector3<ArithmeticType>&, const ViewAngles&, sol::constructors<Camera(const omath::Vector3<ArithmeticType>&, const ViewAngles&,
const omath::projection::ViewPort&, const omath::projection::FieldOfView&, const omath::projection::ViewPort&, const omath::projection::FieldOfView&,
ArithmeticType, ArithmeticType)>(), ArithmeticType, ArithmeticType)>());
"look_at", &Camera::look_at, "get_forward", &Camera::get_forward, "get_right", &Camera::get_right,
"get_up", &Camera::get_up, "get_origin", &Camera::get_origin, "get_view_angles",
&Camera::get_view_angles, "get_near_plane", &Camera::get_near_plane, "get_far_plane",
&Camera::get_far_plane, "get_field_of_view", &Camera::get_field_of_view, "set_origin",
&Camera::set_origin, "set_view_angles", &Camera::set_view_angles, "set_view_port",
&Camera::set_view_port, "set_field_of_view", &Camera::set_field_of_view, "set_near_plane",
&Camera::set_near_plane, "set_far_plane", &Camera::set_far_plane,
"get_view_matrix", camera_type["look_at"] = &Camera::look_at;
[](const Camera& cam) -> Mat4X4 camera_type["get_forward"] = &Camera::get_forward;
{ camera_type["get_right"] = &Camera::get_right;
return cam.get_view_matrix(); camera_type["get_up"] = &Camera::get_up;
}, camera_type["get_origin"] = &Camera::get_origin;
"get_projection_matrix", camera_type["get_view_angles"] = &Camera::get_view_angles;
[](const Camera& cam) -> Mat4X4 camera_type["get_near_plane"] = &Camera::get_near_plane;
{ camera_type["get_far_plane"] = &Camera::get_far_plane;
return cam.get_projection_matrix(); camera_type["get_field_of_view"] = &Camera::get_field_of_view;
}, camera_type["set_origin"] = &Camera::set_origin;
"get_view_projection_matrix", camera_type["set_view_angles"] = &Camera::set_view_angles;
[](const Camera& cam) -> Mat4X4 camera_type["set_view_port"] = &Camera::set_view_port;
{ camera_type["set_field_of_view"] = &Camera::set_field_of_view;
return cam.get_view_projection_matrix(); camera_type["set_near_plane"] = &Camera::set_near_plane;
}, camera_type["set_far_plane"] = &Camera::set_far_plane;
"extract_projection_params",
[](const Mat4X4& projection_matrix)
{
const auto params = Camera::extract_projection_params(projection_matrix);
return std::make_tuple(params.fov, params.aspect_ratio);
},
"calc_view_angles_from_view_matrix", &Camera::calc_view_angles_from_view_matrix,
"calc_origin_from_view_matrix", &Camera::calc_origin_from_view_matrix,
"world_to_screen", camera_type["get_view_matrix"] = [](const Camera& cam) -> Mat4X4
[](const Camera& cam, const omath::Vector3<ArithmeticType>& pos) {
-> std::tuple<sol::optional<omath::Vector3<ArithmeticType>>, sol::optional<std::string>> return cam.get_view_matrix();
{ };
auto result = cam.world_to_screen(pos); camera_type["get_projection_matrix"] = [](const Camera& cam) -> Mat4X4
if (result) {
return {*result, sol::nullopt}; return cam.get_projection_matrix();
return {sol::nullopt, projection_error_to_string(result.error())}; };
}, camera_type["get_view_projection_matrix"] = [](const Camera& cam) -> Mat4X4
{
return cam.get_view_projection_matrix();
};
camera_type["extract_projection_params"] = [](const Mat4X4& projection_matrix)
{
const auto params = Camera::extract_projection_params(projection_matrix);
return std::make_tuple(params.fov, params.aspect_ratio);
};
camera_type["calc_view_angles_from_view_matrix"] = &Camera::calc_view_angles_from_view_matrix;
camera_type["calc_origin_from_view_matrix"] = &Camera::calc_origin_from_view_matrix;
"screen_to_world", camera_type["world_to_screen"] = [](const Camera& cam, const omath::Vector3<ArithmeticType>& pos)
[](const Camera& cam, const omath::Vector3<ArithmeticType>& pos) -> std::tuple<sol::optional<omath::Vector3<ArithmeticType>>, sol::optional<std::string>>
-> std::tuple<sol::optional<omath::Vector3<ArithmeticType>>, sol::optional<std::string>> {
{ auto result = cam.world_to_screen(pos);
auto result = cam.screen_to_world(pos); if (result)
if (result) return {*result, sol::nullopt};
return {*result, sol::nullopt}; return {sol::nullopt, projection_error_to_string(result.error())};
return {sol::nullopt, projection_error_to_string(result.error())}; };
});
camera_type["screen_to_world"] = [](const Camera& cam, const omath::Vector3<ArithmeticType>& pos)
-> std::tuple<sol::optional<omath::Vector3<ArithmeticType>>, sol::optional<std::string>>
{
auto result = cam.screen_to_world(pos);
if (result)
return {*result, sol::nullopt};
return {sol::nullopt, projection_error_to_string(result.error())};
};
} }
// ---- Engine trait structs ----------------------------------------------- // ---- Engine trait structs -----------------------------------------------