fix motion vectors going through gate
[carveJwlIkooP6JGAAIwe30JlM.git] / player_physics.h
index f395953932e19003e93cac528d76c538cb99531e..b6283bf3c6353fa1c4f31000e201a6fc88371556 100644 (file)
@@ -1092,6 +1092,15 @@ VG_STATIC void player_do_motion(void)
          m3x3_mulv( gate->transport, phys->m, phys->m );
          m3x3_mulv( gate->transport, phys->bob, phys->bob );
 
+         /* Pre-emptively edit the camera matrices so that the motion vectors 
+          * are correct */
+         m4x3f transport_i;
+         m4x4f transport_4;
+         m4x3_invert_affine( gate->transport, transport_i );
+         m4x3_expand( transport_i, transport_4 );
+         m4x4_mul( main_camera.mtx.pv, transport_4, main_camera.mtx.pv );
+         m4x4_mul( main_camera.mtx.v, transport_4, main_camera.mtx.v );
+
          v4f transport_rotation;
          m3x3_q( gate->transport, transport_rotation );
          q_mul( transport_rotation, phys->rb.q, phys->rb.q );