v3_cross( localplayer.basis[1], player_walk.state.drop_in_normal, axis );
v3_cross( axis, player_walk.state.drop_in_normal, init_dir );
v3_normalize( init_dir );
- v3_muls( init_dir, 7.0f, vec );
+ v3_muls( init_dir, 4.25f, vec );
}
static float player_xyspeed2(void){
static struct skeleton_anim *player_walk_outro_anim( enum walk_outro type ){
struct player_walk *w = &player_walk;
+ if( type >= k_walk_outro_max )
+ return NULL;
+
return (struct skeleton_anim *[]){
[k_walk_outro_none] = NULL,
[k_walk_outro_jump_to_air] = w->anim_jump_to_air,
if( !localplayer.immobile )
player_look( localplayer.angles, skaterift.time_rate );
+ v2f steer;
+ joystick_state( k_srjoystick_steer, steer );
+
+ if( w->state.activity == k_walk_activity_sit ){
+ if( w->state.sit_t < 1.0f )
+ w->state.sit_t = vg_minf( 1.0f, w->state.sit_t + vg.time_delta );
+
+ if( button_down(k_srbind_sit) || (v2_length2(steer)>0.2f) ||
+ button_down(k_srbind_jump) ){
+ w->state.activity = k_walk_activity_sit_up;
+ }
+ return;
+ }
+ else if( w->state.activity == k_walk_activity_sit_up ){
+ if( w->state.sit_t > 0.0f )
+ w->state.sit_t = vg_maxf( 0.0f, w->state.sit_t - vg.time_delta );
+ else
+ w->state.activity = k_walk_activity_ground;
+
+ if( button_down(k_srbind_sit) )
+ w->state.activity = k_walk_activity_sit;
+
+ return;
+ }
+ else if( w->state.activity == k_walk_activity_ground ){
+ if( button_down(k_srbind_sit) ){
+ v3_zero( localplayer.rb.v );
+ w->state.activity = k_walk_activity_sit;
+ return;
+ }
+ }
+
+ w->state.sit_t = 0.0f;
+
if( w->state.outro_type ){
struct skeleton_anim *anim = player_walk_outro_anim(w->state.outro_type);
w->state.outro_start_time = vg.time;
localplayer.immobile = 1;
- struct player_avatar *av = localplayer.playeravatar;
- m4x3_mulv( localplayer.final_mtx[ av->id_ik_foot_r ],
- av->sk.bones[ av->id_ik_foot_r ].co,
+ u32 foot_id = localplayer.id_ik_foot_r;
+
+ m4x3_mulv( localplayer.final_mtx[ foot_id ],
+ localplayer.skeleton.bones[ foot_id ].co,
w->state.drop_in_foot_anchor );
}
else{
v2f steer;
joystick_state( k_srjoystick_steer, steer );
- if( w->state.activity == k_walk_activity_sit ){
- if( w->state.sit_t < 1.0f )
- w->state.sit_t += vg.time_delta;
- else {
- w->state.sit_t = 1.0f;
-
- if( button_down(k_srbind_sit) || (v2_length2(steer)>0.2f) ||
- button_down(k_srbind_jump) ){
- w->state.activity = k_walk_activity_sit_up;
- }
- }
+ if( (w->state.activity == k_walk_activity_sit) ||
+ (w->state.activity == k_walk_activity_sit_up) ){
return;
}
- else if( w->state.activity == k_walk_activity_sit_up ){
- if( w->state.sit_t > 0.0f ){
- w->state.sit_t -= vg.time_delta;
- return;
- }
- }
- else
- w->state.sit_t = 0.0f;
v3_copy( localplayer.rb.co, w->state.prev_pos );
v3_zero( localplayer.rb.w );
if( w->state.activity == k_walk_activity_ground ){
v3_normalize( surface_avg );
- if( button_down(k_srbind_sit) ){
- w->state.activity = k_walk_activity_sit;
- return;
- }
-
v3f tx, ty;
v3_tangent_basis( surface_avg, tx, ty );
animator->walk_timer = w->state.walk_timer;
- if( !localplayer.immobile )
- rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q );
- else{
+ if( localplayer.immobile || (w->state.outro_type == k_walk_outro_drop_in) ){
v3_copy( localplayer.rb.co, animator->root_co );
v4_copy( localplayer.rb.q, animator->root_q );
}
+ else{
+ rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q );
+ }
f32 walk_yaw = player_get_heading_yaw();
}
if( w->state.outro_type ){
- struct player_avatar *av = localplayer.playeravatar;
struct skeleton_anim *anim =
player_walk_outro_anim( w->state.outro_type );
f32 outro_length = (f32)anim->length / anim->rate,
v3_lerp( w->state.drop_in_start, w->state.drop_in_target,
step_t, localplayer.rb.co );
+ v3_copy( localplayer.rb.co, animator->root_co );
+
+ /* for the camera purposes only */
+ v3f init_velocity;
+ player_walk_drop_in_vector( init_velocity );
+ v3_muls( init_velocity, dop_t, localplayer.rb.v );
+ v3_copy( localplayer.rb.v,
+ localplayer.cam_control.cam_velocity_smooth );
+
q_axis_angle( animator->root_q, (v3f){0.0f,1.0f,0.0f},
walk_yaw + VG_PIf );
/* the drop in bit */
if( step_t >= 1.0f ){
+ v3f final_co;
v4f final_q;
- player_walk_drop_in_overhang_transform( dop_t, localplayer.rb.co,
- final_q );
+ player_walk_drop_in_overhang_transform( dop_t, final_co, final_q );
+
q_mul( final_q, animator->root_q, animator->root_q );
+ v3_copy( final_co, animator->root_co );
+
v4_copy( animator->root_q, localplayer.rb.q );
+ rb_update_transform( &localplayer.rb );
+
v3_muladds( animator->root_co, localplayer.rb.to_world[1],
-0.1f*dop_t, animator->root_co );
+ v3_copy( animator->root_co, localplayer.rb.co );
}
+
return;
}
else{
static void player__walk_pose( void *_animator, player_pose *pose ){
struct player_walk *w = &player_walk;
struct player_walk_animator *animator = _animator;
- struct skeleton *sk = &localplayer.playeravatar->sk;
- struct player_avatar *av = localplayer.playeravatar;
+ struct skeleton *sk = &localplayer.skeleton;
v3_copy( animator->root_co, pose->root_co );
v4_copy( animator->root_q, pose->root_q );
skeleton_sample_anim( sk, w->anim_sit, st*sit_norm, bpose );
v4f qy,qp;
- f32 *qh = bpose[av->id_head-1].q;
+ f32 *qh = bpose[localplayer.id_head-1].q;
q_axis_angle( qy, (v3f){0.0f,1.0f,0.0f}, animator->yaw*0.5f*st );
q_axis_angle( qp, (v3f){0.0f,0.0f,1.0f}, animator->pitch*st );
q_mul( qy, qh, qh );
q_mul( qh, qp, qh );
q_normalize( qh );
- qh = bpose[av->id_chest-1].q;
+ qh = bpose[localplayer.id_chest-1].q;
q_axis_angle( qy, (v3f){0.0f,1.0f,0.0f}, animator->yaw*0.5f*st );
q_mul( qy, qh, qh );
q_normalize( qh );
if( animator->outro_type ){
struct skeleton_anim *anim = player_walk_outro_anim(animator->outro_type);
+
+ if( !anim ){
+ skeleton_copy_pose( sk, apose, pose->keyframes );
+ return;
+ }
f32 outro_length = (f32)anim->length / anim->rate,
outro_time = animator->outro_t*outro_length;
v3f anchored_pos;
m4x3_mulv( inverse, animator->foot_anchor, anchored_pos );
- v3_lerp( pose->keyframes[ av->id_ik_foot_r-1 ].co, anchored_pos,
+ v3_lerp( pose->keyframes[ localplayer.id_ik_foot_r-1 ].co,
+ anchored_pos,
1.0f-animator->commit_t,
- pose->keyframes[ av->id_ik_foot_r-1 ].co );
+ pose->keyframes[ localplayer.id_ik_foot_r-1 ].co );
}
}
else
* Camera
*/
struct player_walk *w = &player_walk;
- struct player_avatar *av = localplayer.playeravatar;
if( w->state.outro_type ){
struct skeleton_anim *anim = player_walk_outro_anim(w->state.outro_type);
static void player__walk_bind(void){
struct player_walk *w = &player_walk;
- struct player_avatar *av = localplayer.playeravatar;
- struct skeleton *sk = &av->sk;
+ struct skeleton *sk = &localplayer.skeleton;
w->anim_idle = skeleton_get_anim( sk, "idle_cycle+y" );
w->anim_walk = skeleton_get_anim( sk, "walk+y" );
bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->run );
bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->walk );
bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->walk_timer );
- bitpack_qf32( ctx, 8, -k_sit_yaw_limit, k_sit_yaw_limit, &animator->yaw );
- bitpack_qf32( ctx, 8, -k_sit_pitch_limit, k_sit_pitch_limit,
- &animator->pitch );
- bitpack_bytes( ctx, 8, &animator->outro_type );
- if( animator->outro_type ){
- bitpack_bytes(ctx, sizeof(animator->foot_anchor), animator->foot_anchor );
- bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->outro_t );
- bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->commit_t );
+ for( int i=0; i<1; i++ ){ /* without this you get a warning from gcc. lol */
+ bitpack_bytes( ctx, 8, &animator->outro_type );
+ if( animator->outro_type ){
+ bitpack_bytes( ctx, sizeof(animator->foot_anchor),
+ animator->foot_anchor );
+ bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->outro_t );
+ bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->commit_t );
+ }
+ }
+
+ u32 code = bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->sit_t );
+ if( code ){
+ bitpack_qf32( ctx, 8, -k_sit_yaw_limit, k_sit_yaw_limit, &animator->yaw );
+ bitpack_qf32( ctx, 8, -k_sit_pitch_limit, k_sit_pitch_limit,
+ &animator->pitch );
}
}
#endif /* PLAYER_DEVICE_WALK_H */