aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/phys/bphysgeneric.cpp
diff options
context:
space:
mode:
authorAlexander <alex@cogarr.net>2019-06-26 16:14:00 -0400
committerAlexander <alex@cogarr.net>2019-06-26 16:14:00 -0400
commitd5cd0c7b4425e25b11a1ceec154a5c752d508a42 (patch)
treeef50cd7d419bba30ee08f46c97232b1c8c68d2be /src/shared/lua_api/phys/bphysgeneric.cpp
parent3d60e1432ec43ade4aa61b5a70dd6b8975417e9f (diff)
downloadbrokengine-d5cd0c7b4425e25b11a1ceec154a5c752d508a42.tar.gz
brokengine-d5cd0c7b4425e25b11a1ceec154a5c752d508a42.tar.bz2
brokengine-d5cd0c7b4425e25b11a1ceec154a5c752d508a42.zip
Major refactor of physics code
Move all the physics code into the shared directory, and fix the ghost objects (aabb only)
Diffstat (limited to 'src/shared/lua_api/phys/bphysgeneric.cpp')
-rw-r--r--src/shared/lua_api/phys/bphysgeneric.cpp41
1 files changed, 14 insertions, 27 deletions
diff --git a/src/shared/lua_api/phys/bphysgeneric.cpp b/src/shared/lua_api/phys/bphysgeneric.cpp
index 56320dd..718ffed 100644
--- a/src/shared/lua_api/phys/bphysgeneric.cpp
+++ b/src/shared/lua_api/phys/bphysgeneric.cpp
@@ -205,6 +205,7 @@ int setdamping(lua_State *L){
return 0;
}
+
/***
Sets flags on this rigidbody
@function rigidbody:setflags(flags)
@@ -223,41 +224,29 @@ int setflags(lua_State *L){
/***
Apply an impulse to the rigidboy
-@function rigidbody:centralimpulse(vec3 impulse)
+@function rigidbody:applyimpulse(vec3 impulse[, vec3 offset])
@tparam vector3 impulse The direction to apply the impulse in
+@tparam? vector3 offset The offset from the center to apply the impulse, default = {0, 0, 0}
*/
+//applyimpuse(self,{pos},{off})
int applyimpulse(lua_State *L){
+ printf("Apply impulse called...\n");
+ int nargs = lua_gettop(L);
double x,y,z,ox,oy,oz;
+ if(nargs > 2){
+ popvector3d(L,&ox,&oy,&oz);
+ }else{
+ ox = 0;
+ oy = 0;
+ oz = 0;
+ }
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;
}
-//collider:setpos({x,y,z})
-int setpos(lua_State *L){
- double x,y,z;
- popvector3d(L,&x,&y,&z);
- lua_getfield(L,-1,"collider");
- btCollisionObject *c = (btCollisionObject*)lua_touserdata(L,-1);
- lua_pop(L,1);
- btTransform t = c->getWorldTransform();
- t.setOrigin(btVector3(x,y,z));
- c->setWorldTransform(t);
- c->activate();
- return 0;
-}
-//collider:getpos() :: {x,y,z}
-int getpos(lua_State *L){
- lua_getfield(L,-1,"collider");
- btCollisionObject *c = (btCollisionObject*)lua_touserdata(L,-1);
- btTransform t = c->getWorldTransform();
- btVector3 o = t.getOrigin();
- pushvector3d(L,o.x(), o.y(), o.z());
- return 1;
-}
/*
A callback used to detect collisions
@@ -296,9 +285,7 @@ extern const luaL_reg brigidbody_m[] = {
{"getldamping", getlineardamping},
{"getadamping", getangulardamping},
{"setdamping", setdamping},
- {"getpos", getpos},
- {"setpos", setpos},
- //{"activate", activate},
+ //{"activate", activate}, --moved to bcollider_m
{"getvelocity", getvelocity},
{"setvelocity", setvelocity},
{"setangfactor", setangfactor},