vehicle stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / player_physics.h
index 6afc1b2c43b0f3e1cf560e83ca1baceb9836a05b..31590d8fb36bb34aab8c1cf75b67b8045b4837af 100644 (file)
@@ -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;