aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/phys
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/lua_api/phys')
-rw-r--r--src/shared/lua_api/phys/bgame.cpp13
-rw-r--r--src/shared/lua_api/phys/bphysbox.cpp21
2 files changed, 29 insertions, 5 deletions
diff --git a/src/shared/lua_api/phys/bgame.cpp b/src/shared/lua_api/phys/bgame.cpp
new file mode 100644
index 0000000..b755787
--- /dev/null
+++ b/src/shared/lua_api/phys/bgame.cpp
@@ -0,0 +1,13 @@
+extern "C" {
+ #include <lua.h>
+ #include <lauxlib.h>
+ #include <lualib.h>
+}
+
+#include <btBulletDynamicsCommon.h>
+
+extern btDiscreteDynamicsWorld* World;
+
+void registergravity(lua_State* L){
+
+}
diff --git a/src/shared/lua_api/phys/bphysbox.cpp b/src/shared/lua_api/phys/bphysbox.cpp
index 3036cf9..78f1c45 100644
--- a/src/shared/lua_api/phys/bphysbox.cpp
+++ b/src/shared/lua_api/phys/bphysbox.cpp
@@ -45,25 +45,34 @@ void makenewbphysbox(lua_State* L){
btVector3 pos = btVector3(px,py,pz);
// Set the initial position of the object
- btTransform transform;
- transform.setIdentity();
- transform.setOrigin(pos);
+ btTransform transform = btTransform(btQuaternion(0,0,0,1),pos);
+ //transform.setIdentity();
+ //transform.setOrigin(pos);
// Give it a default MotionState
btDefaultMotionState* motionstate = new btDefaultMotionState(transform);
-
+ if(!motionstate){
+ printf("No motionstate\n");
+ }
// Create the shape
btCollisionShape* shape = new btBoxShape(vshape);
+ if(!shape){
+ printf("no shape\n");
+ }
// Add mass
- btVector3 localinertia;
+ btVector3 localinertia = btVector3(0,0,0);
shape->calculateLocalInertia(mass, localinertia);
// Create the rigid body object
btRigidBody* rigidbody = new btRigidBody(mass, motionstate, shape, localinertia);
+ if(!rigidbody){
+ printf("No rigidbody\n");
+ }
// Add it to the world
World->addRigidBody(rigidbody);
+ printf("Added rigid body to world: %p\n",World);
Objects.push_back(rigidbody);
lua_pushlightuserdata(L,rigidbody);//ud_rigidbody
@@ -114,6 +123,7 @@ static int bphyssetpos(lua_State *L){//self,{v3 pos}
bt.setOrigin(to);
ms->setWorldTransform(bt);
i->activate();
+
lua_pop(L,1);//
return 0;
}
@@ -139,6 +149,7 @@ static const luaL_reg bphysbox_m[] = {
};
void bphysbox_register(lua_State* L){//
+ printf("Registered bphysbox\n");
luaL_newmetatable(L, "phys.physbox");//{phys.physbox}
lua_newtable(L);//{phys.physbox},{}