- {
- 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 );
- }
- }
-
-
- 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 );
-
- 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( !phys->on_board )
- {
- player.angles[0] = atan2f( -phys->rb.forward[2],
- -phys->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() )
- {
- phys->on_board ^= 0x1;
-
- audio_lock();
- if( phys->on_board )
- {
- v3_muladds( phys->rb.v, phys->rb.forward, 0.2f, phys->rb.v );
- audio_play_oneshot( &audio_lands[6], 1.0f );
- }
- else
- {
- audio_play_oneshot( &audio_lands[5], 1.0f );
- }
-
- audio_unlock();
- }
-
- if( !phys->on_board )
- player_mouseview();
-}
-
-VG_STATIC void player_update_fixed(void) /* 2 */
-{
- if( player.rewinding )
- return;
-
- if( player.death_tick_allowance )
- player.death_tick_allowance --;
-
- struct player_phys *phys = &player.phys;
-
- if( player.is_dead )
- {
- player_ragdoll_iter();
- }
- else
- {
- player.rewind_incrementer ++;
-
- if( player.rewind_incrementer > (u32)(0.25/VG_TIMESTEP_FIXED) )
- {
- player_save_rewind_frame();
- }
-
- player_do_motion();
- }
-}
-
-VG_STATIC void player_update_post(void)
-{
- for( int i=0; i<player.prediction_count; i++ )
- {
- struct land_prediction *p = &player.predictions[i];
-
- for( int j=0; j<p->log_length - 1; j ++ )
- vg_line( p->log[j], p->log[j+1], p->colour );
-
- vg_line_cross( p->log[p->log_length-1], p->colour, 0.25f );
-
- v3f p1;
- v3_add( p->log[p->log_length-1], p->n, p1 );
- vg_line( p->log[p->log_length-1], p1, 0xffffffff );
- }
-
- if( player.is_dead )
- {
- player_debug_ragdoll();