aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/phys/bphysgeneric.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/lua_api/phys/bphysgeneric.cpp')
-rw-r--r--src/shared/lua_api/phys/bphysgeneric.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/shared/lua_api/phys/bphysgeneric.cpp b/src/shared/lua_api/phys/bphysgeneric.cpp
index 44c789d..5faef2d 100644
--- a/src/shared/lua_api/phys/bphysgeneric.cpp
+++ b/src/shared/lua_api/phys/bphysgeneric.cpp
@@ -18,7 +18,12 @@ extern "C" {
node = ISceneNode,
}
*/
-
+btRigidBody* popRigidBody(lua_State *L){
+ lua_getfield(L,-1,"rigidbody");
+ btRigidBody *r = (btRigidBody*)lua_touserdata(L,-1);
+ lua_pop(L,2);
+ return r;
+}
/***
Sets the direction of gravity on this object.
@function rigidbody:setgravity({x,y,z})
@@ -215,9 +220,42 @@ int setdamping(lua_State *L){
return 0;
}
+/***
+Sets flags on this rigidbody
+@function rigidbody:setflags(flags)
+@tparam number flags
+*/
+int setflags(lua_State *L){
+ int flags = lua_tonumber(L,-1);
+ lua_pop(L,1);
+
+ lua_getfield(L,-1,"rigidbody");
+ btRigidBody *r = (btRigidBody*)lua_touserdata(L,-1);
+ lua_pop(L,2);
+
+ r->setFlags(flags);
+
+ return 0;
+}
+
+/***
+Apply an impulse to the rigidboy
+@function rigidbody:centralimpulse(vec3 impulse)
+@tparam vector3 impulse The direction to apply the impulse in
+*/
+int applyimpulse(lua_State *L){
+ double x,y,z,ox,oy,oz;
+ popvector3d(L,&x,&y,&z);
+ popvector3d(L,&ox,&oy,&oz);
+ btRigidBody *r = popRigidBody(L);
+ r->applyImpulse(btVector3(x,y,z),btVector3(ox,oy,oz));
+ return 0;
+}
+
extern const luaL_reg brigidbody_m[] = {
{"setgravity", setgravity},
{"applyforce", applyforce},
+ {"applyimpulse", applyimpulse},
{"getldamping", getlineardamping},
{"getadamping", getangulardamping},
{"setdamping", setdamping},
@@ -225,5 +263,6 @@ extern const luaL_reg brigidbody_m[] = {
{"getvelocity", getvelocity},
{"setvelocity", setvelocity},
{"setangfactor", setangfactor},
+ {"setflags", setflags},
{NULL, NULL}
};