- limiter = vg_minf( 5.0f, time_to_impact )/5.0f;
- limiter = 1.0f-limiter;
- limiter *= limiter;
- limiter = 1.0f-limiter;
-
-#if 0
- if( fabsf(angle) < 0.9999f )
- {
- v4f correction;
- q_axis_angle( correction, axis,
- acosf(angle)*(1.0f-limiter)*2.0f*VG_TIMESTEP_FIXED );
- q_mul( correction, player->rb.q, player->rb.q );
- }
-#endif
- }
-
- v2f steer = { player->input_js1h->axis.value,
- player->input_js1v->axis.value };
- v2_normalize_clamp( steer );
-
- s->land_dist = time_to_impact;
- v3_copy( target_normal, s->land_normal );
-}
-
-#if 0
-VG_STATIC void skate_get_board_points( player_instance *player,
- v3f front, v3f back )
-{
- v3f pos_front = {0.0f,0.0f,-k_board_length},
- pos_back = {0.0f,0.0f, k_board_length};
-
- m4x3_mulv( player->rb.to_world, pos_front, front );
- m4x3_mulv( player->rb.to_world, pos_back, back );
-}
-#endif
-
-#if 0
-/*
- * Casts and pushes a sphere-spring model into the world
- */
-VG_STATIC int skate_simulate_spring( player_instance *player,
- v3f pos )
-{
- struct player_skate *s = &player->_skate;
-
- float mod = 0.7f * player->input_grab->axis.value + 0.3f,
- spring_k = mod * k_spring_force,
- damp_k = mod * k_spring_dampener,
- disp_k = 0.4f;
-
- v3f start, end;
- v3_copy( pos, start );
- v3_muladds( pos, player->rb.to_world[1], -disp_k, end );
-
- float t;
- v3f n;
- int hit_info = spherecast_world( start, end, 0.2f, &t, n );
-
- if( hit_info != -1 )
- {
- v3f F, delta;
- v3_sub( start, player->rb.co, delta );
-
- float displacement = vg_clampf( 1.0f-t, 0.0f, 1.0f ),
- damp =
- vg_maxf( 0.0f, v3_dot( player->rb.to_world[1], player->rb.v ) );
-
- v3_muls( player->rb.to_world[1], displacement*spring_k*k_rb_delta -
- damp*damp_k*k_rb_delta, F );
-
- v3_muladds( player->rb.v, F, 1.0f, player->rb.v );
-
- /* Angular velocity */
- v3f wa;
- v3_cross( delta, F, wa );
- v3_muladds( player->rb.w, wa, k_spring_angular, player->rb.w );
-
- v3_lerp( start, end, t, pos );
- return 1;
- }
- else
- {
- v3_copy( end, pos );
- return 0;
- }
-}
-#endif
-
-
-/*
- * Handles connection between the player and the ground
- *
- * TODO: Must save original velocity to use here
- */
-VG_STATIC void skate_apply_interface_model( player_instance *player,
- rb_ct *manifold, int len )
-{
- struct player_skate *s = &player->_skate;
-
- /* springs */
-
-#if 0
- v3f spring0, spring1;
-
- skate_get_board_points( player, spring1, spring0 );
- int spring_hit0 = 0, //skate_simulate_spring( player, s, spring0 ),
- spring_hit1 = 0; //skate_simulate_spring( player, s, spring1 );
-
- v3f animavg, animdelta;
- v3_add( spring0, spring1, animavg );
- v3_muls( animavg, 0.5f, animavg );
-
- v3_sub( spring1, spring0, animdelta );
- v3_normalize( animdelta );
-
- m4x3_mulv( player->rb.to_local, animavg, s->board_offset );
-
- float dx = -v3_dot( animdelta, player->rb.to_world[2] ),
- dy = v3_dot( animdelta, player->rb.to_world[1] );
-
- float angle = -atan2f( dy, dx );
- q_axis_angle( s->board_rotation, (v3f){1.0f,0.0f,0.0f}, angle );
-
- int lift_frames_limit = 6;
-
- /* Surface connection */
- if( len == 0 && !(spring_hit0 && spring_hit1) )
- {
- s->state.lift_frames ++;
-
- if( s->state.lift_frames >= lift_frames_limit )
- s->state.activity = k_skate_activity_air;
- }
- else
- {
- v3f surface_avg;
- v3_zero( surface_avg );
-
- for( int i=0; i<len; i++ )
- v3_add( surface_avg, manifold[i].n, surface_avg );
- v3_normalize( surface_avg );
-
- if( v3_dot( player->rb.v, surface_avg ) > 0.7f )
- {
- s->state.lift_frames ++;
-
- if( s->state.lift_frames >= lift_frames_limit )
- s->state.activity = k_skate_activity_air;
- }
- else
- {
- s->state.activity = k_skate_activity_ground;
- s->state.lift_frames = 0;
- v3f projected, axis;
-
- if( s->state.activity_prev == k_skate_activity_air )
- {
- player->cam_land_punch_v += v3_dot( player->rb.v, surface_avg ) *
- k_cam_punch;
- }
-
- float const DOWNFORCE = -k_downforce*VG_TIMESTEP_FIXED;
- v3_muladds( player->rb.v, player->rb.to_world[1],
- DOWNFORCE, player->rb.v );
-
- float d = v3_dot( player->rb.to_world[2], surface_avg );
- v3_muladds( surface_avg, player->rb.to_world[2], -d, projected );
- v3_normalize( projected );
-
- float angle = v3_dot( player->rb.to_world[1], projected );
- v3_cross( player->rb.to_world[1], projected, axis );
-
-#if 0
- if( fabsf(angle) < 0.9999f )
- {
- v4f correction;
- q_axis_angle( correction, axis,
- acosf(angle)*4.0f*VG_TIMESTEP_FIXED );
- q_mul( correction, player->rb.q, player->rb.q );
- }
-#endif
- }
- }
-#endif