From 18b9c8cdae81acfef18424375cbc80145b93b68a Mon Sep 17 00:00:00 2001 From: bjorn Date: Mon, 15 May 2017 23:14:46 -0600 Subject: [PATCH] Body:getAngularDamping; Body:setAngularDamping; --- src/api/types/body.c | 19 +++++++++++++++++++ src/physics/physics.c | 10 ++++++++++ src/physics/physics.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/src/api/types/body.c b/src/api/types/body.c index b1443e34..dfb7ca78 100644 --- a/src/api/types/body.c +++ b/src/api/types/body.c @@ -96,6 +96,23 @@ int l_lovrBodySetLinearDamping(lua_State* L) { return 0; } +int l_lovrBodyGetAngularDamping(lua_State* L) { + Body* body = luax_checktype(L, 1, Body); + float damping, threshold; + lovrBodyGetAngularDamping(body, &damping, &threshold); + lua_pushnumber(L, damping); + lua_pushnumber(L, threshold); + return 2; +} + +int l_lovrBodySetAngularDamping(lua_State* L) { + Body* body = luax_checktype(L, 1, Body); + float damping = luaL_checknumber(L, 2); + float threshold = luaL_optnumber(L, 3, .01); + lovrBodySetAngularDamping(body, damping, threshold); + return 0; +} + const luaL_Reg lovrBody[] = { { "getPosition", l_lovrBodyGetPosition }, { "setPosition", l_lovrBodySetPosition }, @@ -107,5 +124,7 @@ const luaL_Reg lovrBody[] = { { "setAngularVelocity", l_lovrBodySetAngularVelocity }, { "getLinearDamping", l_lovrBodyGetLinearDamping }, { "setLinearDamping", l_lovrBodySetLinearDamping }, + { "getAngularDamping", l_lovrBodyGetAngularDamping }, + { "setAngularDamping", l_lovrBodySetAngularDamping }, { NULL, NULL } }; diff --git a/src/physics/physics.c b/src/physics/physics.c index 8571b0dd..f7939e50 100644 --- a/src/physics/physics.c +++ b/src/physics/physics.c @@ -150,3 +150,13 @@ void lovrBodySetLinearDamping(Body* body, float damping, float threshold) { dBodySetLinearDamping(body->id, damping); dBodySetLinearDampingThreshold(body->id, threshold); } + +void lovrBodyGetAngularDamping(Body* body, float* damping, float* threshold) { + *damping = dBodyGetAngularDamping(body->id); + *threshold = dBodyGetAngularDampingThreshold(body->id); +} + +void lovrBodySetAngularDamping(Body* body, float damping, float threshold) { + dBodySetAngularDamping(body->id, damping); + dBodySetAngularDampingThreshold(body->id, threshold); +} diff --git a/src/physics/physics.h b/src/physics/physics.h index e7211a7e..39d26b50 100644 --- a/src/physics/physics.h +++ b/src/physics/physics.h @@ -39,3 +39,5 @@ 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); +void lovrBodyGetAngularDamping(Body* body, float* damping, float* threshold); +void lovrBodySetAngularDamping(Body* body, float damping, float threshold);