X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_physics.h;h=31590d8fb36bb34aab8c1cf75b67b8045b4837af;hb=d45f2b7d71311ce5ce8cd3496844b4ec7d2f46ac;hp=6afc1b2c43b0f3e1cf560e83ca1baceb9836a05b;hpb=0124cd309a7db70cdd74b5661f2df8b862ca2f2f;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_physics.h b/player_physics.h index 6afc1b2..31590d8 100644 --- a/player_physics.h +++ b/player_physics.h @@ -80,6 +80,11 @@ VG_STATIC int spherecast_world( v3f pa, v3f pb, float r, float *t, v3f n ) v3f dir; v3_sub( pb, pa, dir ); + v3f dir_inv; + dir_inv[0] = 1.0f/dir[0]; + dir_inv[1] = 1.0f/dir[1]; + dir_inv[2] = 1.0f/dir[2]; + int hit = -1; float min_t = 1.0f; @@ -100,7 +105,8 @@ VG_STATIC int spherecast_world( v3f pa, v3f pb, float r, float *t, v3f n ) v3_add( (v3f){ r, r, r}, box[1], box[1] ); v3_add( (v3f){-r,-r,-r}, box[0], box[0] ); - if( !ray_aabb( box, pa, dir, 1.0f ) ) + + if( !ray_aabb1( box, pa, dir_inv, 1.0f ) ) continue; float t;