+ v3f v;
+
+ if( player_xyspeed2() < 0.1f * 0.1f )
+ q_mulv( localplayer.rb.q, (v3f){0.0f,0.0f,1.6f}, v );
+ else
+ v3_copy( localplayer.rb.v, v );
+
+ player_skate.state.activity_prev = k_skate_activity_ground;
+ player_skate.state.activity = init;
+
+ v3f dir;
+ v3_copy( v, dir );
+ v3_normalize( dir );
+
+ q_axis_angle( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f},
+ atan2f(-dir[0],-dir[2]) );
+ q_normalize( localplayer.rb.q );
+
+ q_mulv( localplayer.rb.q, (v3f){0.0f,1.0f,0.0f}, player_skate.state.cog );
+ v3_add( player_skate.state.cog, localplayer.rb.co, player_skate.state.cog );
+
+ v3_copy( v, player_skate.state.cog_v );
+ v3_copy( v, localplayer.rb.v );
+
+ player__begin_holdout( (v3f){0.0f,0.0f,0.0f} );
+ player__skate_reset_animator();
+ player__skate_clear_mechanics();
+ rb_update_transform( &localplayer.rb );
+ v3_copy( (v3f){yaw,0.0f,0.0f}, player_skate.state.trick_euler );
+
+ if( init == k_skate_activity_air )
+ player__approximate_best_trajectory();
+}
+
+static void player_walk_drop_in_to_skate(void){
+ localplayer.immobile = 0;
+ localplayer.subsystem = k_player_subsystem_skate;
+
+ player_skate.state.activity_prev = k_skate_activity_ground;
+ player_skate.state.activity = k_skate_activity_ground;
+
+ player__begin_holdout( (v3f){0.0f,0.0f,0.0f} );
+ player__skate_clear_mechanics();
+ player__skate_reset_animator();
+
+ v3f init_velocity;
+ player_walk_drop_in_vector( init_velocity );
+
+ rb_update_transform( &localplayer.rb );
+ v3_muladds( localplayer.rb.co, localplayer.rb.to_world[1], 1.0f,
+ player_skate.state.cog );
+ v3_copy( init_velocity, player_skate.state.cog_v );
+ v3_copy( init_velocity, localplayer.rb.v );
+ v3_copy( init_velocity, localplayer.cam_control.cam_velocity_smooth );
+ v3_copy( (v3f){1.0f,0.0f,0.0f}, player_skate.state.trick_euler );
+}
+
+static void player_walk_drop_in_overhang_transform( f32 t, v3f co, v4f q ){
+ v3f axis;
+ v3_cross( (v3f){0,1,0}, player_walk.state.drop_in_normal, axis );
+ v3_normalize( axis );
+
+ float a = acosf( player_walk.state.drop_in_normal[1] ) * t;
+ q_axis_angle( q, axis, a );
+
+ float l = t * 0.5f,
+ heading_angle = player_walk.state.drop_in_angle;
+
+ v3f overhang;
+ overhang[0] = sinf( heading_angle ) * l;
+ overhang[1] = 0.28f * l;
+ overhang[2] = cosf( heading_angle ) * l;
+
+ q_mulv( q, overhang, overhang );
+ v3_add( player_walk.state.drop_in_target, overhang, co );
+}
+
+static int player_walk_scan_for_drop_in(void){
+ world_instance *world = world_current_instance();
+
+ v3f dir, center;
+ q_mulv( localplayer.rb.q, (v3f){0.0f,0.0f,1.0f}, dir );
+ v3_muladds( localplayer.rb.co, localplayer.rb.to_world[1], -1.0f, center );
+
+ ray_hit samples[20];
+ int sample_count = 0;
+
+ for( int i=0; i<20; i ++ ){
+ float t = (float)i * (1.0f/19.0f),
+ s = sinf( t * VG_PIf * 0.25f ),
+ c = cosf( t * VG_PIf * 0.25f );
+
+ v3f ray_dir, pos;
+ v3_muls ( localplayer.rb.to_world[1], -c, ray_dir );
+ v3_muladds( ray_dir, dir, -s, ray_dir );
+ v3_muladds( center, ray_dir, -2.0f, pos );
+
+ ray_hit *ray = &samples[ sample_count ];
+ ray->dist = 2.0f;
+
+ if( ray_world( world, pos, ray_dir, ray, 0 ) ){
+ vg_line( pos, ray->pos, VG__RED );
+ vg_line_point( ray->pos, 0.025f, VG__BLACK );
+
+ sample_count ++;
+ }
+ }
+
+ float min_a = 0.70710678118654752f;
+ ray_hit *candidate = NULL;
+
+ if( sample_count >= 2 ){
+ for( int i=0; i<sample_count-1; i++ ){
+ ray_hit *s0 = &samples[i],
+ *s1 = &samples[i+1];
+
+ float a = v3_dot( s0->normal, s1->normal );
+
+ if( (a < min_a) && (a >= -0.1f) && (s0->normal[1]>s1->normal[1]) ){
+ min_a = a;
+ candidate = s0;
+ }