7 static void player__dead_update(void){
8 player_ragdoll_iter( &localplayer
.ragdoll
);
11 static void player__dead_post_update(void){
12 struct ragdoll_part
*part
=
13 &localplayer
.ragdoll
.parts
[ localplayer
.id_hip
-1 ];
14 struct player_dead
*d
= &player_dead
;
18 rb_extrapolate( &part
->obj
.rb
, ext_co
, ext_q
);
20 v3_lerp( d
->co_lpf
, ext_co
, vg
.time_frame_delta
*4.0f
, d
->co_lpf
);
21 v3_lerp( d
->v_lpf
, part
->obj
.rb
.v
, vg
.time_frame_delta
*4.0f
, d
->v_lpf
);
22 v3_lerp( d
->w_lpf
, part
->obj
.rb
.w
, vg
.time_frame_delta
*4.0f
, d
->w_lpf
);
24 v3_copy( d
->co_lpf
, localplayer
.rb
.co
);
25 v3_zero( localplayer
.rb
.v
);
26 v3_zero( localplayer
.rb
.w
);
28 if( (skaterift
.activity
== k_skaterift_default
) &&
29 button_down(k_srbind_dead_respawn
) ){
30 ent_spawn
*spawn
= world_find_closest_spawn(
31 world_current_instance(), localplayer
.rb
.co
);
34 v3_copy( spawn
->transform
.co
, localplayer
.rb
.co
);
36 srinput
.state
= k_input_state_resume
;
39 vg_error( "No spawns!\n" );
44 static void player__dead_animate(void){
45 struct player_dead
*d
= &player_dead
;
46 struct player_dead_animator
*animator
= &d
->animator
;
47 struct player_ragdoll
*rd
= &localplayer
.ragdoll
;
48 struct skeleton
*sk
= &localplayer
.skeleton
;
50 m4x3f transforms
[ 32 ];
53 q_m3x3( localplayer
.rb
.q
, transforms
[0] );
54 v3_copy( localplayer
.rb
.co
, transforms
[0][3] );
56 v4_copy( localplayer
.rb
.q
, animator
->transforms
[0].q
);
57 v3_copy( localplayer
.rb
.co
, animator
->transforms
[0].co
);
59 /* colliders with bones transforms */
60 for( int i
=0; i
<rd
->part_count
; i
++ ){
61 struct ragdoll_part
*part
= &rd
->parts
[i
];
68 float substep
= vg
.time_fixed_extrapolate
;
69 v3_lerp( part
->prev_co
, part
->obj
.rb
.co
, substep
, co_int
);
70 q_nlerp( part
->prev_q
, part
->obj
.rb
.q
, substep
, q_int
);
71 v4_copy( part
->obj
.rb
.q
, q_int
);
74 v3_copy( co_int
, mtx
[3] );
76 m4x3_mul( mtx
, part
->inv_collider_mtx
, transforms
[part
->bone_id
] );
79 /* bones without colliders transforms */
80 for( u32 i
=1; i
<sk
->bone_count
; i
++ ){
81 struct skeleton_bone
*sb
= &sk
->bones
[i
];
83 if( sb
->parent
&& !sb
->collider
){
85 v3_sub( sk
->bones
[i
].co
, sk
->bones
[sb
->parent
].co
, delta
);
88 m3x3_identity( posemtx
);
89 v3_copy( delta
, posemtx
[3] );
92 m4x3_mul( transforms
[sb
->parent
], posemtx
, transforms
[i
] );
97 for( u32 i
=1; i
<sk
->bone_count
; i
++ ){
98 struct skeleton_bone
*sb
= &sk
->bones
[i
];
100 v3_zero( animator
->transforms
[i
].co
);
101 q_identity( animator
->transforms
[i
].q
);
103 m4x3f parent
, inverse
, local
;
104 m3x3_identity( parent
);
105 v3_sub( sk
->bones
[i
].co
, sk
->bones
[sb
->parent
].co
, parent
[3] );
106 m4x3_mul( transforms
[ sb
->parent
], parent
, parent
);
107 m4x3_invert_affine( parent
, inverse
);
110 m4x3_mul( inverse
, transforms
[i
], local
);
111 m4x3_decompose( local
, animator
->transforms
[i
].co
,
112 animator
->transforms
[i
].q
, _s
);
116 static void player__dead_pose( void *_animator
, player_pose
*pose
){
117 struct player_dead_animator
*animator
= _animator
;
118 struct player_ragdoll
*rd
= &localplayer
.ragdoll
;
119 struct skeleton
*sk
= &localplayer
.skeleton
;
121 pose
->type
= k_player_pose_type_fk_2
;
122 pose
->board
.lean
= 0.0f
;
124 v3_copy( animator
->transforms
[0].co
, pose
->root_co
);
125 v4_copy( animator
->transforms
[0].q
, pose
->root_q
);
127 for( u32 i
=1; i
<sk
->bone_count
; i
++ ){
128 v3_copy( animator
->transforms
[i
].co
, pose
->keyframes
[i
-1].co
);
129 v4_copy( animator
->transforms
[i
].q
, pose
->keyframes
[i
-1].q
);
130 v3_fill( pose
->keyframes
[i
-1].s
, 1.0f
);
134 static void player__dead_post_animate(void){
135 localplayer
.cam_velocity_influence
= 1.0f
;
138 static void player__dead_im_gui(void){
141 static void player__dead_transition(void){
142 localplayer
.subsystem
= k_player_subsystem_dead
;
143 copy_localplayer_to_ragdoll( &localplayer
.ragdoll
, localplayer
.rb
.v
);
145 struct ragdoll_part
*part
=
146 &localplayer
.ragdoll
.parts
[ localplayer
.id_hip
-1 ];
147 v3_copy( part
->obj
.rb
.co
, player_dead
.co_lpf
);
148 v3_copy( part
->obj
.rb
.v
, player_dead
.v_lpf
);
149 v3_copy( part
->obj
.rb
.w
, player_dead
.w_lpf
);
154 struct gui_helper
*h
;
155 if( (h
= gui_new_helper(input_button_list
[k_srbind_reset
], &str
) )){
156 vg_strcat( &str
, "rewind" );
158 if( world_static
.active_instance
== k_world_purpose_hub
)
162 if( gui_new_helper(input_button_list
[k_srbind_dead_respawn
], &str
))
163 vg_strcat( &str
, "spawn" );
166 static void player__dead_animator_exchange( bitpack_ctx
*ctx
, void *data
){
167 struct player_dead_animator
*animator
= data
;
169 for( u32 i
=0; i
<localplayer
.skeleton
.bone_count
; i
++ ){
170 bitpack_qv3f( ctx
, 24, -1024.0f
, 1024.0f
, animator
->transforms
[i
].co
);
171 bitpack_qquat( ctx
, animator
->transforms
[i
].q
);
175 #endif /* PLAYER_DEAD_C */