Merge branch 'main' into physics-upgrade

This commit is contained in:
MihailRis 2026-03-05 12:16:23 +03:00
commit 1d4fb9bc07
9 changed files with 79 additions and 21 deletions

View file

@ -229,6 +229,20 @@ static int l_look_at(lua::State* L) {
}
}
static int l_perspective(lua::State *L) {
uint argc = lua::check_argc(L, 4, 5);
double fov = glm::radians(lua::tonumber(L, 1));
double ratio = lua::tonumber(L, 2);
double near = lua::tonumber(L, 3);
double far = lua::tonumber(L, 4);
glm::mat4 mat = glm::perspective(fov, ratio, near, far);
if (argc == 5) return lua::setmat4(L, 5, mat);
else return lua::pushmat4(L, mat);
}
static int l_from_quat(lua::State* L) {
uint argc = lua::check_argc(L, 1, 2);
auto quat = lua::toquat(L, 1);
@ -280,6 +294,7 @@ const luaL_Reg mat4lib[] = {
{"determinant", lua::wrap<l_determinant>},
{"decompose", lua::wrap<l_decompose>},
{"look_at", lua::wrap<l_look_at>},
{"perspective", lua::wrap<l_perspective>},
{"from_quat", lua::wrap<l_from_quat>},
{"tostring", lua::wrap<l_tostring>},
{nullptr, nullptr}

View file

@ -44,8 +44,17 @@ static int l_tostring(lua::State* L) {
return lua::pushstring(L, ss.str());
}
static int l_from_euler(lua::State *L) {
uint argc = lua::check_argc(L, 1, 2);
glm::vec3 euler = glm::radians(lua::tovec3(L, 1));
if (argc == 2) return lua::setquat(L, 2, glm::quat(euler));
return lua::pushquat(L, glm::quat(euler));
}
const luaL_Reg quatlib[] = {
{"from_mat4", lua::wrap<l_from_mat4>},
{"from_euler", lua::wrap<l_from_euler>},
{"slerp", lua::wrap<l_slerp>},
{"tostring", lua::wrap<l_tostring>},
{nullptr, nullptr}