q_identity( inst->rb.q );
m4x3_identity( inst->rb.to_world );
m4x3_identity( inst->rb.to_local );
-
- inst->rewind_length = 0;
- inst->rewind_buffer =
- vg_linear_alloc( vg_mem.rtmemory,
- sizeof(struct rewind_frame) * PLAYER_REWIND_FRAMES );
-
}
/*
* ----------------------------------------------------------------------------
*/
-VG_STATIC void player_save_rewind_frame( player_instance *player )
-{
- if( player->rewind_length < PLAYER_REWIND_FRAMES ){
- struct rewind_frame *fr =
- &player->rewind_buffer[ player->rewind_length ++ ];
-
- v2_copy( player->cam.angles, fr->ang );
- v3_copy( player->cam.pos, fr->pos );
-
- if( player->rewind_length >= 2 ){
- player->rewind_total_length +=
- v3_dist( player->rewind_buffer[player->rewind_length-1].pos,
- player->rewind_buffer[player->rewind_length-2].pos );
- }
- }
-}
-
PLAYER_API
-void player__pre_update( player_instance *player )
-{
- if( player->rewinding ){
- return;
- }
-
+void player__pre_update( player_instance *player ){
if( button_down( k_srbind_reset ) && !player->immobile ){
- f64 delta = world_static.time - world_static.last_use;
-
- if( (delta <= RESET_MAX_TIME) && (world_static.last_use != 0.0) ){
- player->rewinding = 1;
- player->rewind_sound_wait = 1;
- player->rewind_time = (double)player->rewind_length - 0.0001;
- player_save_rewind_frame( player );
-
- audio_lock();
- audio_oneshot( &audio_rewind[0], 1.0f, 0.0f );
- audio_unlock();
-
- /* based on 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->rewind_start = vg.time;
- player->subsystem = player->subsystem_gate;
- player->rb = player->rb_gate_storage;
- v3_copy( player->angles_storage, player->angles );
-
- if( _player_restore[ player->subsystem ] )
- _player_restore[ player->subsystem ]( player );
+ if( player->subsystem == k_player_subsystem_dead ){
+ localplayer_cmd_respawn( 0, NULL );
}
else{
- if( player->subsystem == k_player_subsystem_dead ){
- localplayer_cmd_respawn( 0, NULL );
- }
- else{
- /* cant do that */
- audio_lock();
- audio_oneshot( &audio_rewind[4], 1.0f, 0.0f );
- audio_unlock();
- }
+ /* cant do that */
+ audio_lock();
+ audio_oneshot( &audio_rewind[4], 1.0f, 0.0f );
+ audio_unlock();
}
}
if( button_down( k_srbind_camera ) && !player->immobile ){
- if( player->camera_mode == k_cam_firstperson )
- player->camera_mode = k_cam_thirdperson;
+ if( player->cam_control.camera_mode == k_cam_firstperson )
+ player->cam_control.camera_mode = k_cam_thirdperson;
else
- player->camera_mode = k_cam_firstperson;
+ player->cam_control.camera_mode = k_cam_firstperson;
}
if( _player_pre_update[ player->subsystem ] )
}
PLAYER_API
-void player__update( player_instance *player )
-{
- if( player->rewinding )
- return;
-
+void player__update( player_instance *player ){
if( _player_update[ player->subsystem ] )
_player_update[ player->subsystem ]( player );
}
PLAYER_API
-void player__post_update( player_instance *player )
-{
- if( player->rewinding )
- return;
-
+void player__post_update( player_instance *player ){
if( _player_post_update[ player->subsystem ] )
_player_post_update[ player->subsystem ]( player );
-
- if((player->subsystem != k_player_subsystem_dead) && !player->gate_waiting){
- player->rewind_accum += vg.time_frame_delta;
-
- if( player->rewind_accum > 0.25f ){
- player->rewind_accum -= 0.25f;
- player_save_rewind_frame( player );
- }
- }
}
/*
player->gate_waiting = gate;
world_routes_activate_entry_gate( world_current_instance(), gate );
- m4x3_mulv( gate->transport, player->tpv_lpf, player->tpv_lpf );
- m3x3_mulv( gate->transport, player->cam_velocity_smooth,
- player->cam_velocity_smooth );
-
+ struct player_cam_controller *cc = &player->cam_control;
+ m4x3_mulv( gate->transport, cc->tpv_lpf, cc->tpv_lpf );
+ m3x3_mulv( gate->transport, cc->cam_velocity_smooth,
+ cc->cam_velocity_smooth );
m3x3_copy( player->basis, player->basis_gate );
v4f q;
q_m3x3( player->qbasis, player->basis );
m3x3_transpose( player->basis, player->invbasis );
- player->subsystem_gate = player->subsystem;
- player->rb_gate_storage = player->rb;
- v3_copy( player->angles, player->angles_storage );
- player->rewind_length = 0;
- player->rewind_total_length = 0.0f;
- player->rewind_gate = gate;
- player->rewind_accum = 0.0f;
-
m4x3_mulv( gate->transport, player->cam.pos, player->cam.pos );
- player_save_rewind_frame( player );
if( gate->type == k_gate_type_nonlocel )
world_static.active_world = gate->target;
player->subsystem = k_player_subsystem_walk;
player->immobile = 0;
player->gate_waiting = NULL;
- player->rewind_length = 0;
- player->rewind_accum = 0.0f;
- player->rewind_gate = NULL;
- player->rewinding = 0;
world_static.last_use = 0.0;
global_skateshop_exit();