Merge pull request #848 from Astazium/main

ObjParser and GBuffer refactor + fixes
This commit is contained in:
MihailRis 2026-10-15 23:18:29 +03:00 • committed by GitHub
commit c64659e06d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 212 additions and 279 deletions

View file

@ -71,6 +71,9 @@ static int l_get_def(lua::State* L) {
static int l_spawn(lua::State* L) {
auto level = controller->getLevel();
auto defname = lua::tostring(L, 1);
if (defname == nullptr) {
throw std::runtime_error("string expected, got nil");
}
auto& def = content->entities.require(defname);
auto pos = lua::tovec3(L, 2);
dv::value args = nullptr;

View file

@ -211,59 +211,36 @@ static int l_tostring(lua::State* L) {
return lua::pushstring(L, ss.str());
}
#define VECLIB_BASE(n) \
{"add", lua::wrap<l_binop<n, std::plus>>}, \
{"sub", lua::wrap<l_binop<n, std::minus>>}, \
{"mul", lua::wrap<l_binop<n, std::multiplies>>}, \
{"div", lua::wrap<l_binop<n, std::divides>>}, \
{"distance", lua::wrap<l_distance<n>>}, \
{"normalize", lua::wrap<l_unaryop<n, glm::normalize>>}, \
{"length", lua::wrap<l_scalar_op<n, glm::length>>}, \
{"tostring", lua::wrap<l_tostring<n>>}, \
{"abs", lua::wrap<l_unaryop<n, glm::abs>>}, \
{"round", lua::wrap<l_unaryop<n, glm::round>>}, \
{"inverse", lua::wrap<l_inverse<n>>}, \
{"pow", lua::wrap<l_pow<n>>}, \
{"dot", lua::wrap<l_dot<n>>}, \
{"mix", lua::wrap<l_mix<n>>},
const luaL_Reg vec2lib[] = {
{"add", lua::wrap<l_binop<2, std::plus>>},
{"sub", lua::wrap<l_binop<2, std::minus>>},
{"mul", lua::wrap<l_binop<2, std::multiplies>>},
{"div", lua::wrap<l_binop<2, std::divides>>},
{"distance", lua::wrap<l_distance<2>>},
{"normalize", lua::wrap<l_unaryop<2, glm::normalize>>},
{"length", lua::wrap<l_scalar_op<2, glm::length>>},
{"tostring", lua::wrap<l_tostring<2>>},
{"abs", lua::wrap<l_unaryop<2, glm::abs>>},
{"round", lua::wrap<l_unaryop<2, glm::round>>},
{"inverse", lua::wrap<l_inverse<2>>},
{"pow", lua::wrap<l_pow<2>>},
{"dot", lua::wrap<l_dot<2>>},
VECLIB_BASE(2)
{"angle", lua::wrap<l_vec2_angle>},
{"mix", lua::wrap<l_mix<2>>},
{"rotate", lua::wrap<l_vec2_rotate>},
{nullptr, nullptr}
};
const luaL_Reg vec3lib[] = {
{"add", lua::wrap<l_binop<3, std::plus>>},
{"sub", lua::wrap<l_binop<3, std::minus>>},
{"mul", lua::wrap<l_binop<3, std::multiplies>>},
{"div", lua::wrap<l_binop<3, std::divides>>},
{"distance", lua::wrap<l_distance<3>>},
{"normalize", lua::wrap<l_unaryop<3, glm::normalize>>},
{"length", lua::wrap<l_scalar_op<3, glm::length>>},
{"tostring", lua::wrap<l_tostring<3>>},
{"abs", lua::wrap<l_unaryop<3, glm::abs>>},
{"round", lua::wrap<l_unaryop<3, glm::round>>},
{"inverse", lua::wrap<l_inverse<3>>},
{"pow", lua::wrap<l_pow<3>>},
{"dot", lua::wrap<l_dot<3>>},
VECLIB_BASE(3)
{"spherical_rand", lua::wrap<l_spherical_rand>},
{"mix", lua::wrap<l_mix<3>>},
{nullptr, nullptr}
};
const luaL_Reg vec4lib[] = {
{"add", lua::wrap<l_binop<4, std::plus>>},
{"sub", lua::wrap<l_binop<4, std::minus>>},
{"mul", lua::wrap<l_binop<4, std::multiplies>>},
{"div", lua::wrap<l_binop<4, std::divides>>},
{"distance", lua::wrap<l_distance<4>>},
{"normalize", lua::wrap<l_unaryop<4, glm::normalize>>},
{"length", lua::wrap<l_scalar_op<4, glm::length>>},
{"tostring", lua::wrap<l_tostring<4>>},
{"abs", lua::wrap<l_unaryop<4, glm::abs>>},
{"round", lua::wrap<l_unaryop<4, glm::round>>},
{"inverse", lua::wrap<l_inverse<4>>},
{"pow", lua::wrap<l_pow<4>>},
{"dot", lua::wrap<l_dot<4>>},
{"mix", lua::wrap<l_mix<4>>},
VECLIB_BASE(4)
{nullptr, nullptr}
};