add player guide
[carveJwlIkooP6JGAAIwe30JlM.git] / player_dead.c
1 #ifndef PLAYER_DEAD_C
2 #define PLAYER_DEAD_C
3
4 #include "player.h"
5
6 VG_STATIC void player__dead_update ( player_instance *player )
7 {
8 player_ragdoll_iter( &player->ragdoll );
9 }
10
11 VG_STATIC void player__dead_animate ( player_instance *player,
12 player_animation *anim )
13 {
14 v3_zero( anim->root_co );
15 q_identity( anim->root_q );
16
17 for( int i=0; i<vg_list_size( anim->pose ); i ++ ){
18 v3_zero( anim->pose[i].co );
19 v3_fill( anim->pose[i].s, 1.0f );
20 q_identity( anim->pose[i].q );
21 }
22 }
23
24 VG_STATIC void player__dead_post_animate( player_instance *player )
25 {
26 struct player_avatar *av = player->playeravatar;
27 struct player_dead *d = &player->_dead;
28
29 copy_ragdoll_pose_to_avatar( &player->ragdoll, player->playeravatar );
30 player->cam_velocity_influence = 1.0f;
31
32 struct ragdoll_part *part = &player->ragdoll.parts[ av->id_hip-1 ];
33
34 v3f ext_co;
35 v4f ext_q;
36 rb_extrapolate( &part->obj.rb, ext_co, ext_q );
37
38 v3_lerp( d->co_lpf, ext_co, vg.time_frame_delta*4.0f, d->co_lpf );
39 v3_lerp( d->v_lpf, part->obj.rb.v, vg.time_frame_delta*4.0f, d->v_lpf );
40 v3_lerp( d->w_lpf, part->obj.rb.w, vg.time_frame_delta*4.0f, d->w_lpf );
41
42 v3_copy( d->co_lpf, player->rb.co );
43 v3_zero( player->rb.v );
44 v3_zero( player->rb.w );
45 }
46
47 VG_STATIC void player__dead_im_gui ( player_instance *player )
48 {
49
50 }
51
52 VG_STATIC void player__dead_transition ( player_instance *player )
53 {
54 player->subsystem = k_player_subsystem_dead;
55 copy_avatar_pose_to_ragdoll( player->playeravatar, &player->ragdoll,
56 player->rb.v );
57
58 struct player_avatar *av = player->playeravatar;
59 struct ragdoll_part *part = &player->ragdoll.parts[ av->id_hip-1 ];
60 struct player_dead *d = &player->_dead;
61 v3_copy( part->obj.rb.co, d->co_lpf );
62 v3_copy( part->obj.rb.v, d->v_lpf );
63 v3_copy( part->obj.rb.w, d->w_lpf );
64 }
65
66 #endif /* PLAYER_DEAD_C */