-VG_STATIC void player_do_motion(void);
-/*
- * Free camera movement
- */
-VG_STATIC void player_mouseview(void)
-{
- if( menu_enabled() )
- return;
-
- v2_muladds( player.angles, vg.mouse_delta, 0.0025f, player.angles );
-
- if( vg_input.controller_should_use_trackpad_look )
- {
- static v2f last_input;
- static v2f vel;
- static v2f vel_smooth;
-
- v2f input = { player.input_js2h->axis.value,
- player.input_js2v->axis.value };
-
- if( (v2_length2(last_input) > 0.001f) && (v2_length2(input) > 0.001f) )
- {
- v2_sub( input, last_input, vel );
- v2_muls( vel, 1.0f/vg.time_delta, vel );
- }
- else
- {
- v2_zero( vel );
- }
-
- v2_lerp( vel_smooth, vel, vg.time_delta*8.0f, vel_smooth );
-
- v2_muladds( player.angles, vel_smooth, vg.time_delta, player.angles );
- v2_copy( input, last_input );
- }
- else
- {
- player.angles[0] += player.input_js2h->axis.value * vg.time_delta * 4.0f;
- player.angles[1] += player.input_js2v->axis.value * vg.time_delta * 4.0f;
- }
-
- player.angles[1] = vg_clampf( player.angles[1], -VG_PIf*0.5f, VG_PIf*0.5f );
-}
-
-/* Deal with input etc */
-VG_STATIC void player_update_pre(void)
-{
-
- {
- v3f ra, rb, rx;
- v3_copy( main_camera.pos, ra );
- v3_muladds( ra, main_camera.transform[2], -10.0f, rb );
-
- float t;
- if( spherecast_world( ra, rb, 0.4f, &t, rx ) != -1 )
- {
- m4x3f mtx;
- m3x3_identity( mtx );
- v3_lerp( ra, rb, t, mtx[3] );
-
- debug_sphere( mtx, 0.4f, 0xff00ff00 );
-
- v3f x1;
- v3_muladds( mtx[3], rx, 0.4f, x1 );
- vg_line( mtx[3], x1, 0xffffffff );
- }
- }
-
-#if 0
-
- vg_line_pt3( phys->cog, 0.10f, 0xffffffff );
- vg_line_pt3( phys->cog, 0.09f, 0xffffffff );
- vg_line_pt3( phys->cog, 0.08f, 0xffffffff );
- vg_line( phys->cog, phys->rb.co, 0xff000000 );
-
- v3f spring_end;
- v3f throw_end, p0, p1;
- v3_muladds( phys->rb.co, phys->rb.up, 1.0f, spring_end );
- v3_muladds( spring_end, phys->throw_v, 1.0f, throw_end );
- v3_muladds( spring_end, player.debug_mmcollect_lat, 1.0f, p0 );
- v3_muladds( spring_end, player.debug_mmcollect_vert, 1.0f, p1 );
- vg_line( spring_end, throw_end, VG__RED );
- vg_line( spring_end, p0, VG__GREEN );
- vg_line( spring_end, p1, VG__BLUE );
-#endif
-
- if( player.rewinding )
- return;
-
- if( vg_input_button_down( player.input_reset ) && !menu_enabled() )
- {
- double delta = world.time - world.last_use;
-
- if( (delta <= RESET_MAX_TIME) && (world.last_use != 0.0) )
- {
- player.rewinding = 1;
- player.rewind_sound_wait = 1;
- player.rewind_time = (float)player.rewind_length - 0.0001f;
- player_save_rewind_frame();
- audio_lock();
- audio_play_oneshot( &audio_rewind[0], 1.0f );
- audio_unlock();
-
- /* based on analytical testing. DONT CHANGE!
- *
- * time taken: y = (x^(4/5)) * 74.5
- * inverse : x = (2/149)^(4/5) * y^(4/5)
- */
-
- float constant = powf( 2.0f/149.0f, 4.0f/5.0f ),
- curve = powf( player.rewind_total_length, 4.0f/5.0f );
-
- player.rewind_predicted_time = constant * curve;
- player.diag_rewind_start = vg.time;
- player.diag_rewind_time = player.rewind_time;
-
- player.is_dead = 0;
- player.death_tick_allowance = 30;
- player_restore_frame();
-
- if( player.controller == k_player_controller_walk )
- {
- player.angles[0] = atan2f( -player.rb.forward[2],
- -player.rb.forward[0] );
- }
-
- player.mdl.shoes[0] = 1;
- player.mdl.shoes[1] = 1;
-
- world_routes_notify_reset();
-
- /* apply 1 frame of movement */
- player_do_motion();
- }
- else
- {
- if( player.is_dead )
- {
- reset_player( 0, NULL );
- }
- else
- {
- /* cant do that */
- audio_lock();
- audio_play_oneshot( &audio_rewind[4], 1.0f );
- audio_unlock();
- }
- }
- }
-
- if( vg_input_button_down( player.input_switch_mode ) && !menu_enabled() )
- {
- audio_lock();
-
-#if 0
- if( phys->controller == k_player_controller_walk )
- {
- phys->controller = k_player_controller_skate;
-
- v3_muladds( phys->rb.v, phys->rb.forward, 0.2f, phys->rb.v );
- audio_play_oneshot( &audio_lands[6], 1.0f );
- }
- else if( phys->controller == k_player_controller_skate )
- {
- phys->controller = k_player_controller_walk;
-
- audio_play_oneshot( &audio_lands[5], 1.0f );
- }
-#endif
-
- audio_unlock();
- }
-
- if( player.controller == k_player_controller_walk )
- player_mouseview();
-}
-
-VG_STATIC void player_update_fixed(void) /* 2 */
-{
- if( player.rewinding )
- return;
-
- if( player.death_tick_allowance )
- player.death_tick_allowance --;
-
- if( player.is_dead )
- {
- player_ragdoll_iter();
- }
- else
- {
- player.rewind_incrementer ++;