mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
Merge branch 'main' into physics-upgrade
This commit is contained in:
commit
1d4fb9bc07
9 changed files with 79 additions and 21 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue