mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
add mass, elasticity getters, setters to entity.rigidbody
This commit is contained in:
parent
1bba713502
commit
bd7f588800
4 changed files with 42 additions and 2 deletions
|
|
@ -164,6 +164,34 @@ static int l_get_material(lua::State* L) {
|
|||
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>},
|
||||
|
|
@ -185,5 +213,9 @@ const luaL_Reg rigidbodylib[] = {
|
|||
{"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}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue