#include #include #include #include extern "C" { #include #include #include } #include #include "../callbackhandeler.hpp" #include "phys/cbphysbox.hpp" #include "phys/cbphysmodel.hpp" #include #include //#include #include using namespace irr; using namespace gui; using namespace core; extern IrrlichtDevice* device; extern btDiscreteDynamicsWorld* World; extern btBroadphaseInterface *BroadPhase; //raytest({from},{to},{mins},{maxes}) :: hashit int raytest(lua_State *L){ double fx,fy,fz; double tx,ty,tz; popvector3d(L, &fx, &fy, &fz); popvector3d(L, &tx, &ty, &tz); btVector3 from(fx, fy, fz); btVector3 to(tx, ty, tz); btCollisionWorld::RayResultCallback *res = new btDiscreteDynamicsWorld::ClosestRayResultCallback(from, to); World->rayTest(from,to,*res); lua_pushboolean(L,res->hasHit()); return 1; } void load_cphysfuncs(lua_State* L){ //phys things cbphysbox_register(L); cbphysmodel_register(L); lua_getglobal(L,"phys");//{} lua_pushcfunction(L,raytest);//{},raytest() lua_setfield(L,-2,"raytest");//{} lua_pop(L,1); }