aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/phys/bghostobject.cpp
diff options
context:
space:
mode:
authorAlexander <alex@cogarr.net>2020-06-29 15:29:03 -0400
committerAlexander <alex@cogarr.net>2020-06-29 15:29:03 -0400
commit80789508b9655d25629223b9dcc84b4cfb77ce45 (patch)
tree37e140e532af61c1ca4699c8b6254cf2cb07ed02 /src/shared/lua_api/phys/bghostobject.cpp
parent44a1421c393632978d59c0698a93ae22243b97e9 (diff)
downloadbrokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.gz
brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.bz2
brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.zip
Updates for mdoc
Also more tests
Diffstat (limited to 'src/shared/lua_api/phys/bghostobject.cpp')
-rw-r--r--src/shared/lua_api/phys/bghostobject.cpp15
1 files changed, 10 insertions, 5 deletions
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;