diff options
| author | Alexander M Pickering <alex@cogarr.net> | 2024-03-02 20:15:09 -0600 |
|---|---|---|
| committer | Alexander M Pickering <alex@cogarr.net> | 2024-03-02 20:15:09 -0600 |
| commit | b1e8adf00231a035148415a7e4c20b1997485066 (patch) | |
| tree | 4d58677f2d0204ff787071447ea3aa80c7f70bf2 /src/shared | |
| parent | ba04b0f24780b8254f5867e80ee1edf28f37a502 (diff) | |
| download | brokengine-b1e8adf00231a035148415a7e4c20b1997485066.tar.gz brokengine-b1e8adf00231a035148415a7e4c20b1997485066.tar.bz2 brokengine-b1e8adf00231a035148415a7e4c20b1997485066.zip | |
Actually return a normalized vector from shapecast
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); |
