diff options
Diffstat (limited to 'src/shared')
| -rw-r--r-- | src/shared/lua_api/load_phys.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/shared/lua_api/load_phys.cpp b/src/shared/lua_api/load_phys.cpp index d20545e..a03c404 100644 --- a/src/shared/lua_api/load_phys.cpp +++ b/src/shared/lua_api/load_phys.cpp @@ -33,7 +33,11 @@ int shapecast(lua_State *L){ //printf("before getting results\n\tHasHit:%d\n\tHit:%f,%f,%f\n\tNor:%f,%f,%f\n",cb->hasHit() ? 1 : 0,hw.x(),hw.y(),hw.z(),hn.x(),hn.y(),hn.z()); World->convexSweepTest(cs,ft,tt,*cb,1.f); hw = cb->m_hitPointWorld; - hn = cb->m_hitNormalWorld; + //Okay, turns out m_hitNormalWorld is not the normal of either of the shapes (although it's usually close): + //https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=3538 + //Not only is it not a normal of either of the shapes or the collision, it's not even a normalized vector, I got it's magnitude as low as 0.90 and as high as 1.11 in testing. + //So we have to normalize it once it comes out. + hn = cb->m_hitNormalWorld.normalized(); //printf("Got sweep results\n\tHasHit:%d\n\tHit:%f,%f,%f\n\tNor:%f,%f,%f\n",cb->hasHit() ? 1 : 0,hw.x(),hw.y(),hw.z(),hn.x(),hn.y(),hn.z()); lua_newtable(L);//{} lua_pushboolean(L,cb->hasHit() ? 1 : 0); |
