X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_walk.c;h=7d09f15e7095708b0b9287b651067da4256856fd;hb=510bec78dcd9d91dd57d8995b573b1fff5256821;hp=99dee8ee7186d27fd9927a02244da3ec61b17603;hpb=7122b79f53f4501751d884c0bf2e838ab501c4a3;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_walk.c b/player_walk.c index 99dee8e..7d09f15 100644 --- a/player_walk.c +++ b/player_walk.c @@ -228,6 +228,9 @@ static int player_walk_scan_for_drop_in(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, @@ -791,10 +794,10 @@ static void player__walk_animate(void){ { f32 head_yaw = localplayer.angles[0] + VG_PIf, y = vg_angle_diff( head_yaw, -walk_yaw ), - mp = VG_PIf / 4.0f, - p = vg_clampf( localplayer.angles[1], -mp, mp ); + p = vg_clampf( localplayer.angles[1], + -k_sit_pitch_limit, k_sit_pitch_limit ); - if( fabsf(y) > VG_PIf/1.7f ){ + if( fabsf(y) > k_sit_yaw_limit ){ y = 0.0f; p = 0.0f; } @@ -911,6 +914,11 @@ static void player__walk_pose( void *_animator, player_pose *pose ){ 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; @@ -1045,11 +1053,21 @@ static void player__walk_animator_exchange( bitpack_ctx *ctx, void *data ){ bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->walk ); bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->walk_timer ); - 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 */