aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/phys/bghostobject.cpp
diff options
context:
space:
mode:
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;