Merge pull request #792 from MihailRis/physics-upgrade

solid entities
This commit is contained in:
MihailRis 2026-03-14 22:56:33 +03:00 • committed by GitHub
commit a78a924093
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 786 additions and 416 deletions

View file

@ -150,6 +150,48 @@ static int l_set_linear_damping(lua::State* L) {
return 0;
}
static int l_set_material(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
entity->getRigidbody().hitbox.material = lua::require_string(L, 2);
}
return 0;
}
static int l_get_material(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
return lua::pushstring(L, entity->getRigidbody().hitbox.material);
}
return 0;
}
static int l_get_mass(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
return lua::pushnumber(L, entity->getRigidbody().mass);
}
return 0;
}
static int l_set_mass(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
entity->getRigidbody().mass = lua::tonumber(L, 2);
}
return 0;
}
static int l_get_elasticity(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
return lua::pushnumber(L, entity->getRigidbody().elasticity);
}
return 0;
}
static int l_set_elasticity(lua::State* L) {
if (auto entity = get_entity(L, 1)) {
entity->getRigidbody().elasticity = lua::tonumber(L, 2);
}
return 0;
}
const luaL_Reg rigidbodylib[] = {
{"is_enabled", lua::wrap<l_is_enabled>},
{"set_enabled", lua::wrap<l_set_enabled>},
@ -169,5 +211,11 @@ const luaL_Reg rigidbodylib[] = {
{"set_crouching", lua::wrap<l_set_crouching>},
{"get_body_type", lua::wrap<l_get_body_type>},
{"set_body_type", lua::wrap<l_set_body_type>},
{"set_material", lua::wrap<l_set_material>},
{"get_material", lua::wrap<l_get_material>},
{"get_mass", lua::wrap<l_get_mass>},
{"set_mass", lua::wrap<l_set_mass>},
{"get_elasticity", lua::wrap<l_get_elasticity>},
{"set_elasticity", lua::wrap<l_set_elasticity>},
{nullptr, nullptr}
};

View file

@ -31,7 +31,7 @@ static int l_set_pos(lua::State* L) {
auto vec = lua::tovec3(L, 2);
check_valid(vec);
entity->getTransform().setPos(vec);
entity->getRigidbody().hitbox.position = vec;
entity->getRigidbody().hitbox.setPos(vec);
}
return 0;
}