+
+ struct player_walk *w = &player->_walk;
+ struct player_skate *s = &player->_skate;
+ s->state.activity_prev = k_skate_activity_ground;
+ s->state.activity = k_skate_activity_ground;
+
+ player__skate_clear_mechanics( player );
+ player__skate_reset_animator( player );
+
+ v3f init_velocity;
+ player_walk_drop_in_vector( player, init_velocity );
+
+ rb_update_transform( &player->rb );
+ v3_muladds( player->rb.co, player->rb.to_world[1], 1.0f, s->state.cog );
+ v3_copy( init_velocity, s->state.cog_v );
+ v3_copy( init_velocity, player->rb.v );
+ v3_copy( init_velocity, player->cam_velocity_smooth );
+}
+
+VG_STATIC int player_walk_scan_for_drop_in( player_instance *player )
+{
+ struct player_walk *w = &player->_walk;
+
+ v3f dir, center;
+ q_mulv( player->rb.q, (v3f){0.0f,0.0f,1.0f}, dir );
+ v3_muladds( player->rb.co, player->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 ( player->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( pos, ray_dir, ray ) )
+ {
+ vg_line( pos, ray->pos, VG__RED );
+ vg_line_pt3( 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;
+ }
+ }
+ }
+
+ if( candidate )
+ {
+ v4f pa, pb, pc;
+
+ ray_hit *s0 = candidate,
+ *s1 = candidate+1;
+
+ vg_line( s0->pos, s1->pos, VG__WHITE );
+
+ v3_copy( s0->normal, pa );
+ v3_copy( s1->normal, pb );
+ v3_cross( player->rb.to_world[1], dir, pc );
+ v3_normalize( pc );
+
+ pa[3] = v3_dot( pa, s0->pos );
+ pb[3] = v3_dot( pb, s1->pos );
+ pc[3] = v3_dot( pc, player->rb.co );
+
+ v3f edge;
+ if( plane_intersect3( pa, pb, pc, edge ) )
+ {
+ v3_copy( edge, w->state.drop_in_target );
+ v3_copy( s1->normal, w->state.drop_in_normal );
+
+ player_walk_drop_in_vector( player, player->rb.v );
+ return 1;
+ }
+ else
+ {
+ vg_error( "failed to find intersection of drop in\n" );
+ }
+ }
+
+ return 0;