From 2009501214f3c2e3f8d8b1a06432afdf39276bd5 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Wed, 7 Nov 2018 14:49:35 -0500 Subject: Added Kinematic Character Controllers --- src/client/lua_api/load_cphys.cpp | 4 +--- src/client/lua_api/load_cphys.hpp | 2 +- src/client/main.cpp | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/client') diff --git a/src/client/lua_api/load_cphys.cpp b/src/client/lua_api/load_cphys.cpp index b38b84d..ed81408 100644 --- a/src/client/lua_api/load_cphys.cpp +++ b/src/client/lua_api/load_cphys.cpp @@ -40,9 +40,7 @@ int raytest(lua_State *L){ return 1; } -void load_physfuncs(lua_State* L){ - lua_newtable(L);//{} - lua_setglobal(L,"phys");// +void load_cphysfuncs(lua_State* L){ //phys things cbphysbox_register(L); diff --git a/src/client/lua_api/load_cphys.hpp b/src/client/lua_api/load_cphys.hpp index 7ee07fe..5afd102 100644 --- a/src/client/lua_api/load_cphys.hpp +++ b/src/client/lua_api/load_cphys.hpp @@ -10,5 +10,5 @@ extern "C" { } #include -void load_physfuncs(lua_State* L); +void load_cphysfuncs(lua_State* L); #endif diff --git a/src/client/main.cpp b/src/client/main.cpp index bc509c7..e8533d8 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -10,6 +10,7 @@ extern "C" { #include #include +#include #include #include "initdevice.hpp" @@ -20,6 +21,7 @@ extern "C" { #include "lua_api/load_cphys.hpp" #include "lua_api/load_video.hpp" #include "lua_api/load_io.hpp" +#include #include "callbackhandeler.hpp" #include @@ -49,6 +51,7 @@ void loadIrrLibs(lua_State* L, IrrlichtDevice* device){ printf("[OK]\n"); printf("Loading physfuncs..."); load_physfuncs(L); + load_cphysfuncs(L); printf("[OK]\n"); printf("Loading videofuncs..."); load_videofuncs(L); @@ -56,12 +59,18 @@ void loadIrrLibs(lua_State* L, IrrlichtDevice* device){ load_iofuncs(L); } -void RemoveISceneNode(btRigidBody* rb){ +void dropRigidBody(btRigidBody* rb){ ISceneNode *Node = static_cast(rb->getUserPointer()); if(Node) Node->remove(); } +void dropChar(btKinematicCharacterController *a){ + ISceneNode *node = (ISceneNode*)a->getGhostObject()->getUserPointer(); + if(node) + node->remove(); +} + // Converts a quaternion to an euler angle void QuaternionToEuler(const btQuaternion &TQuat, btVector3 &TEuler) { btScalar W = TQuat.getW(); @@ -202,7 +211,8 @@ int main(int argc, char *argv[]){ lua_pop(state,2); } } - phys_shutdown(RemoveISceneNode); + //phys_shutdown(RemoveISceneNode); + phys_shutdown(); device->drop(); printf("Goodbye\n"); -- cgit v1.2.3-70-g09d2