From 80789508b9655d25629223b9dcc84b4cfb77ce45 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 29 Jun 2020 15:29:03 -0400 Subject: Updates for mdoc Also more tests --- src/shared/lua_api/phys/bghostobject.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/shared/lua_api/phys/bghostobject.cpp') diff --git a/src/shared/lua_api/phys/bghostobject.cpp b/src/shared/lua_api/phys/bghostobject.cpp index 63f790c..5657b5f 100644 --- a/src/shared/lua_api/phys/bghostobject.cpp +++ b/src/shared/lua_api/phys/bghostobject.cpp @@ -109,7 +109,7 @@ int bghostconvexsweep(lua_State *L){ btVector3 hw, hn; hw = cb->m_hitPointWorld; hn = cb->m_hitNormalWorld; - btCollisionObject *co = cb->m_hitCollisionObject; + const btCollisionObject *co = cb->m_hitCollisionObject; lua_newtable(L);//{} lua_pushboolean(L,cb->hasHit() ? 1 : 0); @@ -118,12 +118,17 @@ int bghostconvexsweep(lua_State *L){ lua_setfield(L,-2,"pos"); pushvector3d(L,hn.x(),hn.y(),hn.z()); lua_setfield(L,-2,"normal"); + lua_getglobal(L,"phys");//{},{phys} lua_getfield(L,-1,"colliders");//{},{phys},{phys.colliders} - lua_pushlightuserdata(L,co);//{},{phys},{phys.colliders},ud_collisionobject - lua_gettable(L,-2);//{},{phys},{phys.colliders},ud_collisionobject,{rb} or nil - lua_setfield(L,-5,"what");//{},{phys},{phys.colliders},ud_collisionobject - lua_pop(L,3);//{} + lua_pushlightuserdata(L,(void*)co);//{},{phys},{phys.colliders},ud_collisionobject + lua_gettable(L,-2);//{},{phys},{phys.colliders},{rb} or nil + if(lua_isnil(L,-1)){ + lua_pop(L,3);//{} + }else{ + lua_setfield(L,-4,"what");//{},{phys},{phys.colliders} + lua_pop(L,2);//{} + } delete cb; return 1; -- cgit v1.2.3-70-g09d2