+ int iair = state->activity <= k_skate_activity_air_to_grind;
+
+ float dirz = state->reverse > 0.0f? 0.0f: 1.0f,
+ fly = iair? 1.0f: 0.0f,
+ wdist= player_skate.weight_distribution[2] / k_board_length;
+
+ if( state->activity >= k_skate_activity_grind_any )
+ wdist = 0.0f;
+
+ animator->z = vg_lerpf( animator->z, dirz, 2.4f*vg.time_delta );
+ animator->skid = state->skid;
+ animator->fly = vg_lerpf( animator->fly, fly, 3.4f*vg.time_delta );
+ animator->weight = vg_lerpf( animator->weight, wdist, 9.0f*vg.time_delta );
+
+ float stand = 1.0f - vg_clampf( curspeed * 0.03f, 0.0f, 1.0f );
+ animator->stand = vg_lerpf( animator->stand, stand, 6.0f*vg.time_delta );
+ animator->reverse = state->reverse;
+
+ if( fabsf(state->slip) > 0.3f ){
+ f32 slide_x = v3_dot(localplayer.rb.v, localplayer.rb.to_world[0]);
+ state->delayed_slip_dir = vg_signf(slide_x);
+ }
+
+ /* grinding */
+ f32 grind=state->activity >= k_skate_activity_grind_any? 1.0f: 0.0f;
+ animator->grind = vg_lerpf( animator->grind, grind, 5.0f*vg.time_delta );
+
+ f32 grind_frame = 0.5f;
+
+ if( state->activity == k_skate_activity_grind_front50 )
+ grind_frame = 0.0f;
+ else if( state->activity == k_skate_activity_grind_back50 )
+ grind_frame = 1.0f;
+
+ animator->grind_balance = vg_lerpf( animator->grind_balance, grind_frame,
+ 5.0f*vg.time_delta );
+ animator->activity = state->activity;
+ animator->surface = player_skate.surface;
+
+ /* pushing */
+ animator->push_time = vg.time - state->start_push;
+ animator->push = vg_lerpf( animator->push,
+ (vg.time - state->cur_push) < 0.125,
+ 6.0f*vg.time_delta );
+
+ /* jumping */
+ animator->jump_charge = state->jump_charge;
+ animator->jump = vg_lerpf( animator->jump, animator->jump_charge,
+ 8.4f*vg.time_delta );
+
+ /* trick setup */
+ animator->jump_dir = state->jump_dir;
+ f32 jump_start_frame = 14.0f/30.0f;
+ animator->jump_time = animator->jump_charge * jump_start_frame;
+ f32 jump_frame = (vg.time - state->jump_time) + jump_start_frame;
+ if( jump_frame >= jump_start_frame && jump_frame <= (40.0f/30.0f) )
+ animator->jump_time = jump_frame;
+
+ /* trick */
+ float jump_t = vg.time-state->jump_time;
+ float k=17.0f;
+ float h = k*jump_t;
+ float extra = h*exp(1.0-h) * (state->jump_dir?1.0f:-1.0f);
+ extra *= state->slap * 4.0f;
+
+ v3_add( state->trick_euler, state->trick_residuald,
+ animator->board_euler );
+ v3_muls( animator->board_euler, VG_TAUf, animator->board_euler );
+
+ animator->board_euler[0] *= 0.5f;
+ animator->board_euler[1] += extra;
+ animator->trick_type = state->trick_type;
+
+ /* board lean */
+ f32 lean1, lean2 = animator->steer[0] * animator->reverse * -0.36f,
+ lean;
+
+ lean1 = animator->slide * animator->delayed_slip_dir;
+ if( fabsf(lean1)>fabsf(lean2) ) lean = lean1;
+ else lean = lean2;
+
+ if( ((int)roundf(animator->board_euler[0]/VG_PIf)) % 2 ) lean = -lean;
+ lean = vg_clampf( lean, -1.0f, 1.0f );
+ animator->board_lean =
+ vg_lerpf(animator->board_lean, lean, vg.time_delta*18.0f);
+
+ /* feet placement */
+ struct player_board *board =
+ addon_cache_item_if_loaded( k_addon_type_board,
+ localplayer.board_view_slot );
+ if( board ){
+ if( animator->weight > 0.0f ){
+ animator->foot_offset[0] =
+ board->truck_positions[k_board_truck_back][2]+0.3f;
+ }
+ else{
+ animator->foot_offset[1] =
+ board->truck_positions[k_board_truck_front][2]-0.3f;
+ }
+ }
+
+ f32 slapm = vg_maxf( 1.0f-v3_length2( state->trick_vel ), 0.0f );
+ animator->slap = state->slap;
+ animator->subslap = vg_lerpf( animator->subslap, slapm,
+ vg.time_delta*10.0f );
+
+#if 0
+ f32 l = ((state->activity < k_skate_activity_ground) &&
+ v3_length2(state->trick_vel) > 0.1f )? 1: 0;
+ animator->trick_foot = vg_lerpf( animator->trick_foot, l,
+ 8.4f*vg.time_delta );
+#endif
+
+ animator->trick_foot = vg_exp_impulse( state->trick_time, 5.0f );
+
+ /* grab */
+ v2f grab_input;
+ joystick_state( k_srjoystick_grab, grab_input );
+ v2_add( state->grab_mouse_delta, grab_input, grab_input );
+
+ if( v2_length2( grab_input ) <= 0.001f ) grab_input[0] = -1.0f;
+ else v2_normalize_clamp( grab_input );
+ v2_lerp( animator->grab, grab_input, 2.4f*vg.time_delta, animator->grab );
+ animator->grabbing = state->grabbing;
+
+ /* steer */
+ v2f steer;
+ joystick_state( k_srjoystick_steer, steer );
+ animator->airdir = vg_lerpf( animator->airdir,
+ -steer[0], 2.4f*vg.time_delta );
+
+ animator->steer[0] = steer[0];
+ animator->steer[1] = vg_lerpf( animator->steer[1],
+ steer[0], 4.0f*vg.time_delta );
+
+
+ /* flip angle */
+ if( (state->activity <= k_skate_activity_air_to_grind) &&
+ (fabsf(state->flip_rate) > 0.01f) ){
+ float substep = vg.time_fixed_extrapolate;
+ float t = state->flip_time+state->flip_rate*substep*vg.time_fixed_delta;
+ sign = vg_signf( t );
+
+ t = 1.0f - vg_minf( 1.0f, fabsf( t * 1.1f ) );
+ t = sign * (1.0f-t*t);