mirror of https://github.com/bjornbytes/lovr.git
Body:getLinearDamping; Body:setLinearDamping;
This commit is contained in:
parent
d29e190695
commit
1a4193831c
|
@ -79,6 +79,23 @@ int l_lovrBodySetAngularVelocity(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int l_lovrBodyGetLinearDamping(lua_State* L) {
|
||||
Body* body = luax_checktype(L, 1, Body);
|
||||
float damping, threshold;
|
||||
lovrBodyGetLinearDamping(body, &damping, &threshold);
|
||||
lua_pushnumber(L, damping);
|
||||
lua_pushnumber(L, threshold);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int l_lovrBodySetLinearDamping(lua_State* L) {
|
||||
Body* body = luax_checktype(L, 1, Body);
|
||||
float damping = luaL_checknumber(L, 2);
|
||||
float threshold = luaL_optnumber(L, 3, .01);
|
||||
lovrBodySetLinearDamping(body, damping, threshold);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrBody[] = {
|
||||
{ "getPosition", l_lovrBodyGetPosition },
|
||||
{ "setPosition", l_lovrBodySetPosition },
|
||||
|
@ -88,5 +105,7 @@ const luaL_Reg lovrBody[] = {
|
|||
{ "setLinearVelocity", l_lovrBodySetLinearVelocity },
|
||||
{ "getAngularVelocity", l_lovrBodyGetAngularVelocity },
|
||||
{ "setAngularVelocity", l_lovrBodySetAngularVelocity },
|
||||
{ "getLinearDamping", l_lovrBodyGetLinearDamping },
|
||||
{ "setLinearDamping", l_lovrBodySetLinearDamping },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
|
@ -140,3 +140,13 @@ void lovrBodyGetAngularVelocity(Body* body, float* x, float* y, float* z) {
|
|||
void lovrBodySetAngularVelocity(Body* body, float x, float y, float z) {
|
||||
dBodySetAngularVel(body->id, x, y, z);
|
||||
}
|
||||
|
||||
void lovrBodyGetLinearDamping(Body* body, float* damping, float* threshold) {
|
||||
*damping = dBodyGetLinearDamping(body->id);
|
||||
*threshold = dBodyGetLinearDampingThreshold(body->id);
|
||||
}
|
||||
|
||||
void lovrBodySetLinearDamping(Body* body, float damping, float threshold) {
|
||||
dBodySetLinearDamping(body->id, damping);
|
||||
dBodySetLinearDampingThreshold(body->id, threshold);
|
||||
}
|
||||
|
|
|
@ -37,3 +37,5 @@ void lovrBodyGetLinearVelocity(Body* body, float* x, float* y, float* z);
|
|||
void lovrBodySetLinearVelocity(Body* body, float x, float y, float z);
|
||||
void lovrBodyGetAngularVelocity(Body* body, float* x, float* y, float* z);
|
||||
void lovrBodySetAngularVelocity(Body* body, float x, float y, float z);
|
||||
void lovrBodyGetLinearDamping(Body* body, float* damping, float* threshold);
|
||||
void lovrBodySetLinearDamping(Body* body, float damping, float threshold);
|
||||
|
|
Loading…
Reference in New Issue