removed useless header

This commit is contained in:
2026-03-10 17:57:11 +03:00
parent 30e3feb4f8
commit cbdabd3fc2
8 changed files with 116 additions and 128 deletions

View File

@@ -10,4 +10,13 @@ namespace omath::lua
{ {
void register_lib(lua_State* lua_state); void register_lib(lua_State* lua_state);
} }
namespace omath::lua::detail
{
void register_vec2(sol::table& omath_table);
void register_vec3(sol::table& omath_table);
void register_vec4(sol::table& omath_table);
void register_color(sol::table& omath_table);
void register_shared_types(sol::table& omath_table);
void register_engines(sol::table& omath_table);
}
#endif #endif

View File

@@ -1,17 +0,0 @@
//
// Created by orange on 07.03.2026.
//
#pragma once
#ifdef OMATH_ENABLE_LUA
#include <sol/sol.hpp>
namespace omath::lua::detail
{
void register_vec2(sol::table& omath_table);
void register_vec3(sol::table& omath_table);
void register_vec4(sol::table& omath_table);
void register_color(sol::table& omath_table);
void register_shared_types(sol::table& omath_table);
void register_engines(sol::table& omath_table);
}
#endif

View File

@@ -3,7 +3,7 @@
// //
#ifdef OMATH_ENABLE_LUA #ifdef OMATH_ENABLE_LUA
#include "lua.hpp" #include "lua.hpp"
#include "internal.hpp" #include <sol/sol.hpp>
#include "omath/lua/lua.hpp" #include "omath/lua/lua.hpp"
namespace omath::lua namespace omath::lua

View File

@@ -2,7 +2,8 @@
// Created by orange on 07.03.2026. // Created by orange on 07.03.2026.
// //
#ifdef OMATH_ENABLE_LUA #ifdef OMATH_ENABLE_LUA
#include "internal.hpp" #include "omath/lua/lua.hpp"
#include <sol/sol.hpp>
#include <omath/utility/color.hpp> #include <omath/utility/color.hpp>
namespace omath::lua::detail namespace omath::lua::detail
@@ -11,38 +12,35 @@ namespace omath::lua::detail
{ {
omath_table.new_usertype<omath::Color>( omath_table.new_usertype<omath::Color>(
"Color", "Color",
sol::factories( sol::factories([](float r, float g, float b, float a) { return omath::Color(r, g, b, a); },
[](float r, float g, float b, float a) { return omath::Color(r, g, b, a); },
[]() { return omath::Color(); }), []() { return omath::Color(); }),
"from_rgba", [](uint8_t r, uint8_t g, uint8_t b, uint8_t a) { "from_rgba", [](uint8_t r, uint8_t g, uint8_t b, uint8_t a)
return omath::Color::from_rgba(r, g, b, a); { return omath::Color::from_rgba(r, g, b, a); }, "from_hsv",
}, sol::overload([](float h, float s, float v) { return omath::Color::from_hsv(h, s, v); },
"from_hsv", sol::overload(
[](float h, float s, float v) { return omath::Color::from_hsv(h, s, v); },
[](const omath::Hsv& hsv) { return omath::Color::from_hsv(hsv); }), [](const omath::Hsv& hsv) { return omath::Color::from_hsv(hsv); }),
"red", []() { return omath::Color::red(); }, "red", []() { return omath::Color::red(); }, "green", []() { return omath::Color::green(); }, "blue",
"green", []() { return omath::Color::green(); }, []() { return omath::Color::blue(); },
"blue", []() { return omath::Color::blue(); },
"r", sol::property([](const omath::Color& c) { return c.value().x; }), "r", sol::property([](const omath::Color& c) { return c.value().x; }), "g",
"g", sol::property([](const omath::Color& c) { return c.value().y; }), sol::property([](const omath::Color& c) { return c.value().y; }), "b",
"b", sol::property([](const omath::Color& c) { return c.value().z; }), sol::property([](const omath::Color& c) { return c.value().z; }), "a",
"a", sol::property([](const omath::Color& c) { return c.value().w; }), sol::property([](const omath::Color& c) { return c.value().w; }),
"to_hsv", &omath::Color::to_hsv, "to_hsv", &omath::Color::to_hsv, "set_hue", &omath::Color::set_hue, "set_saturation",
"set_hue", &omath::Color::set_hue, &omath::Color::set_saturation, "set_value", &omath::Color::set_value, "blend", &omath::Color::blend,
"set_saturation", &omath::Color::set_saturation,
"set_value", &omath::Color::set_value,
"blend", &omath::Color::blend,
sol::meta_function::to_string, &omath::Color::to_string); sol::meta_function::to_string, &omath::Color::to_string);
omath_table.new_usertype<omath::Hsv>( omath_table.new_usertype<omath::Hsv>(
"Hsv", sol::constructors<omath::Hsv()>(), "Hsv", sol::constructors<omath::Hsv()>(), "hue",
"hue", sol::property([](const omath::Hsv& h) { return h.hue; }, [](omath::Hsv& h, float val) { h.hue = val; }), sol::property([](const omath::Hsv& h) { return h.hue; }, [](omath::Hsv& h, float val) { h.hue = val; }),
"saturation", sol::property([](const omath::Hsv& h) { return h.saturation; }, [](omath::Hsv& h, float val) { h.saturation = val; }), "saturation",
"value", sol::property([](const omath::Hsv& h) { return h.value; }, [](omath::Hsv& h, float val) { h.value = val; })); sol::property([](const omath::Hsv& h) { return h.saturation; },
[](omath::Hsv& h, float val) { h.saturation = val; }),
"value",
sol::property([](const omath::Hsv& h) { return h.value; },
[](omath::Hsv& h, float val) { h.value = val; }));
} }
} // namespace omath::lua::detail } // namespace omath::lua::detail
#endif #endif

View File

@@ -2,7 +2,8 @@
// Created by orange on 07.03.2026. // Created by orange on 07.03.2026.
// //
#ifdef OMATH_ENABLE_LUA #ifdef OMATH_ENABLE_LUA
#include "internal.hpp" #include "omath/lua/lua.hpp"
#include <sol/sol.hpp>
#include <omath/engines/cry_engine/camera.hpp> #include <omath/engines/cry_engine/camera.hpp>
#include <omath/engines/cry_engine/constants.hpp> #include <omath/engines/cry_engine/constants.hpp>
#include <omath/engines/frostbite_engine/camera.hpp> #include <omath/engines/frostbite_engine/camera.hpp>
@@ -11,7 +12,6 @@
#include <omath/engines/iw_engine/constants.hpp> #include <omath/engines/iw_engine/constants.hpp>
#include <omath/engines/opengl_engine/camera.hpp> #include <omath/engines/opengl_engine/camera.hpp>
#include <omath/engines/opengl_engine/constants.hpp> #include <omath/engines/opengl_engine/constants.hpp>
#include <omath/engines/opengl_engine/formulas.hpp>
#include <omath/engines/source_engine/camera.hpp> #include <omath/engines/source_engine/camera.hpp>
#include <omath/engines/source_engine/constants.hpp> #include <omath/engines/source_engine/constants.hpp>
#include <omath/engines/unity_engine/camera.hpp> #include <omath/engines/unity_engine/camera.hpp>
@@ -35,7 +35,7 @@ namespace
using ViewAngles90 = omath::ViewAngles<PitchAngle90, SharedYawRoll, SharedYawRoll>; using ViewAngles90 = omath::ViewAngles<PitchAngle90, SharedYawRoll, SharedYawRoll>;
using ViewAngles89 = omath::ViewAngles<PitchAngle89, SharedYawRoll, SharedYawRoll>; using ViewAngles89 = omath::ViewAngles<PitchAngle89, SharedYawRoll, SharedYawRoll>;
static std::string projection_error_to_string(omath::projection::Error e) std::string projection_error_to_string(omath::projection::Error e)
{ {
switch (e) switch (e)
{ {
@@ -51,27 +51,16 @@ namespace
void register_angle(sol::table& table, const char* name) void register_angle(sol::table& table, const char* name)
{ {
table.new_usertype<AngleType>( table.new_usertype<AngleType>(
name, sol::no_constructor, name, sol::no_constructor, "from_degrees", &AngleType::from_degrees, "from_radians",
"from_degrees", &AngleType::from_degrees, &AngleType::from_radians, "as_degrees", &AngleType::as_degrees, "as_radians", &AngleType::as_radians,
"from_radians", &AngleType::from_radians, "sin", &AngleType::sin, "cos", &AngleType::cos, "tan", &AngleType::tan, "cot", &AngleType::cot,
"as_degrees", &AngleType::as_degrees, sol::meta_function::addition, [](const AngleType& a, const AngleType& b)
"as_radians", &AngleType::as_radians, { return AngleType::from_degrees(a.as_degrees() + b.as_degrees()); }, sol::meta_function::subtraction,
"sin", &AngleType::sin,
"cos", &AngleType::cos,
"tan", &AngleType::tan,
"cot", &AngleType::cot,
sol::meta_function::addition,
[](const AngleType& a, const AngleType& b) [](const AngleType& a, const AngleType& b)
{ return AngleType::from_degrees(a.as_degrees() + b.as_degrees()); }, { return AngleType::from_degrees(a.as_degrees() - b.as_degrees()); }, sol::meta_function::unary_minus,
sol::meta_function::subtraction,
[](const AngleType& a, const AngleType& b)
{ return AngleType::from_degrees(a.as_degrees() - b.as_degrees()); },
sol::meta_function::unary_minus,
[](const AngleType& a) { return AngleType::from_degrees(-a.as_degrees()); }, [](const AngleType& a) { return AngleType::from_degrees(-a.as_degrees()); },
sol::meta_function::equal_to, sol::meta_function::equal_to, [](const AngleType& a, const AngleType& b) { return a == b; },
[](const AngleType& a, const AngleType& b) { return a == b; }, sol::meta_function::to_string, [](const AngleType& a) { return std::format("{}deg", a.as_degrees()); });
sol::meta_function::to_string,
[](const AngleType& a) { return std::format("{}deg", a.as_degrees()); });
} }
// Set aliases in an engine subtable pointing to the already-registered shared types // Set aliases in an engine subtable pointing to the already-registered shared types
@@ -110,30 +99,23 @@ namespace
engine_table.new_usertype<Camera>( engine_table.new_usertype<Camera>(
"Camera", "Camera",
sol::constructors<Camera(const omath::Vector3<float>&, const ViewAngles&, sol::constructors<Camera(const omath::Vector3<float>&, const ViewAngles&,
const omath::projection::ViewPort&, const omath::projection::ViewPort&, const omath::projection::FieldOfView&,
const omath::projection::FieldOfView&, float, float)>(), float, float)>(),
"look_at", &Camera::look_at, "look_at", &Camera::look_at, "get_forward", &Camera::get_forward, "get_right", &Camera::get_right,
"get_forward", &Camera::get_forward, "get_up", &Camera::get_up, "get_origin", &Camera::get_origin, "get_view_angles",
"get_right", &Camera::get_right, &Camera::get_view_angles, "get_near_plane", &Camera::get_near_plane, "get_far_plane",
"get_up", &Camera::get_up, &Camera::get_far_plane, "get_field_of_view", &Camera::get_field_of_view, "set_origin",
"get_origin", &Camera::get_origin, &Camera::set_origin, "set_view_angles", &Camera::set_view_angles, "set_view_port",
"get_view_angles", &Camera::get_view_angles, &Camera::set_view_port, "set_field_of_view", &Camera::set_field_of_view, "set_near_plane",
"get_near_plane", &Camera::get_near_plane, &Camera::set_near_plane, "set_far_plane", &Camera::set_far_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,
"world_to_screen", "world_to_screen",
[](const Camera& cam, const omath::Vector3<float>& pos) [](const Camera& cam, const omath::Vector3<float>& pos)
-> std::tuple<sol::optional<omath::Vector3<float>>, sol::optional<std::string>> -> std::tuple<sol::optional<omath::Vector3<float>>, sol::optional<std::string>>
{ {
auto result = cam.world_to_screen(pos); auto result = cam.world_to_screen(pos);
if (result) return {*result, sol::nullopt}; if (result)
return {*result, sol::nullopt};
return {sol::nullopt, projection_error_to_string(result.error())}; return {sol::nullopt, projection_error_to_string(result.error())};
}, },
@@ -142,7 +124,8 @@ namespace
-> std::tuple<sol::optional<omath::Vector3<float>>, sol::optional<std::string>> -> std::tuple<sol::optional<omath::Vector3<float>>, sol::optional<std::string>>
{ {
auto result = cam.screen_to_world(pos); auto result = cam.screen_to_world(pos);
if (result) return {*result, sol::nullopt}; if (result)
return {*result, sol::nullopt};
return {sol::nullopt, projection_error_to_string(result.error())}; return {sol::nullopt, projection_error_to_string(result.error())};
}); });
} }
@@ -205,27 +188,39 @@ namespace omath::lua::detail
register_angle<SharedFoV>(t, "FieldOfView"); register_angle<SharedFoV>(t, "FieldOfView");
t.new_usertype<omath::projection::ViewPort>( t.new_usertype<omath::projection::ViewPort>(
"ViewPort", "ViewPort", sol::factories([](float w, float h) { return omath::projection::ViewPort{w, h}; }), "width",
sol::factories([](float w, float h) { return omath::projection::ViewPort{w, h}; }), sol::property([](const omath::projection::ViewPort& vp) { return vp.m_width; },
"width", sol::property([](const omath::projection::ViewPort& vp) { return vp.m_width; }, [](omath::projection::ViewPort& vp, float val) { vp.m_width = val; }), [](omath::projection::ViewPort& vp, float val) { vp.m_width = val; }),
"height", sol::property([](const omath::projection::ViewPort& vp) { return vp.m_height; }, [](omath::projection::ViewPort& vp, float val) { vp.m_height = val; }), "height",
sol::property([](const omath::projection::ViewPort& vp) { return vp.m_height; },
[](omath::projection::ViewPort& vp, float val) { vp.m_height = val; }),
"aspect_ratio", &omath::projection::ViewPort::aspect_ratio); "aspect_ratio", &omath::projection::ViewPort::aspect_ratio);
t.new_usertype<ViewAngles90>( t.new_usertype<ViewAngles90>(
"ViewAngles90", "ViewAngles90",
sol::factories([](PitchAngle90 p, SharedYawRoll y, SharedYawRoll r) sol::factories([](PitchAngle90 p, SharedYawRoll y, SharedYawRoll r) { return ViewAngles90{p, y, r}; }),
{ return ViewAngles90{p, y, r}; }), "pitch",
"pitch", sol::property([](const ViewAngles90& va) { return va.pitch; }, [](ViewAngles90& va, const PitchAngle90& val) { va.pitch = val; }), sol::property([](const ViewAngles90& va) { return va.pitch; },
"yaw", sol::property([](const ViewAngles90& va) { return va.yaw; }, [](ViewAngles90& va, const SharedYawRoll& val) { va.yaw = val; }), [](ViewAngles90& va, const PitchAngle90& val) { va.pitch = val; }),
"roll", sol::property([](const ViewAngles90& va) { return va.roll; }, [](ViewAngles90& va, const SharedYawRoll& val) { va.roll = val; })); "yaw",
sol::property([](const ViewAngles90& va) { return va.yaw; },
[](ViewAngles90& va, const SharedYawRoll& val) { va.yaw = val; }),
"roll",
sol::property([](const ViewAngles90& va) { return va.roll; },
[](ViewAngles90& va, const SharedYawRoll& val) { va.roll = val; }));
t.new_usertype<ViewAngles89>( t.new_usertype<ViewAngles89>(
"ViewAngles89", "ViewAngles89",
sol::factories([](PitchAngle89 p, SharedYawRoll y, SharedYawRoll r) sol::factories([](PitchAngle89 p, SharedYawRoll y, SharedYawRoll r) { return ViewAngles89{p, y, r}; }),
{ return ViewAngles89{p, y, r}; }), "pitch",
"pitch", sol::property([](const ViewAngles89& va) { return va.pitch; }, [](ViewAngles89& va, const PitchAngle89& val) { va.pitch = val; }), sol::property([](const ViewAngles89& va) { return va.pitch; },
"yaw", sol::property([](const ViewAngles89& va) { return va.yaw; }, [](ViewAngles89& va, const SharedYawRoll& val) { va.yaw = val; }), [](ViewAngles89& va, const PitchAngle89& val) { va.pitch = val; }),
"roll", sol::property([](const ViewAngles89& va) { return va.roll; }, [](ViewAngles89& va, const SharedYawRoll& val) { va.roll = val; })); "yaw",
sol::property([](const ViewAngles89& va) { return va.yaw; },
[](ViewAngles89& va, const SharedYawRoll& val) { va.yaw = val; }),
"roll",
sol::property([](const ViewAngles89& va) { return va.roll; },
[](ViewAngles89& va, const SharedYawRoll& val) { va.roll = val; }));
} }
void register_engines(sol::table& omath_table) void register_engines(sol::table& omath_table)

View File

@@ -2,7 +2,8 @@
// Created by orange on 07.03.2026. // Created by orange on 07.03.2026.
// //
#ifdef OMATH_ENABLE_LUA #ifdef OMATH_ENABLE_LUA
#include "internal.hpp" #include "omath/lua/lua.hpp"
#include <sol/sol.hpp>
#include <omath/linear_algebra/vector2.hpp> #include <omath/linear_algebra/vector2.hpp>
namespace omath::lua::detail namespace omath::lua::detail

View File

@@ -2,7 +2,8 @@
// Created by orange on 07.03.2026. // Created by orange on 07.03.2026.
// //
#ifdef OMATH_ENABLE_LUA #ifdef OMATH_ENABLE_LUA
#include "internal.hpp" #include "omath/lua/lua.hpp"
#include <sol/sol.hpp>
#include <omath/linear_algebra/vector3.hpp> #include <omath/linear_algebra/vector3.hpp>
namespace omath::lua::detail namespace omath::lua::detail

View File

@@ -2,7 +2,8 @@
// Created by orange on 07.03.2026. // Created by orange on 07.03.2026.
// //
#ifdef OMATH_ENABLE_LUA #ifdef OMATH_ENABLE_LUA
#include "internal.hpp" #include "omath/lua/lua.hpp"
#include <sol/sol.hpp>
#include <omath/linear_algebra/vector4.hpp> #include <omath/linear_algebra/vector4.hpp>
namespace omath::lua::detail namespace omath::lua::detail