v3_copy( sj->normal3, n1 );
v3_cross( n0, n1, dir );
- if( v3_length2( dir ) <= 0.001f )
+ if( v3_length2( dir ) <= 0.000001f )
continue;
v3_normalize( dir );
static void skate_grind_truck_apply( float sign, struct grind_info *inf,
float strength ){
struct player_skate_state *state = &player_skate.state;
-
/* REFACTOR */
v3f ra = { 0.0f, -k_board_radius, sign * k_board_length };
v3f raw, wsp;
}
/* yes, we are currently rebuilding mass matrices every frame. too bad! */
- v3f extent = { k_board_width, 0.1f, k_board_length };
+ v3f extent = { k_board_width*10.0f, 0.1f, k_board_length };
float ex2 = k_board_interia*extent[0]*extent[0],
ey2 = k_board_interia*extent[1]*extent[1],
ez2 = k_board_interia*extent[2]*extent[2];
} else if( stick_frames == 0 ){
/* TODO: EXIT SOUNDS */
}
+
+ if( (state->activity_prev < k_skate_activity_grind_any) &&
+ (state->activity >= k_skate_activity_grind_any) ){
+ state->velocity_limit = v3_length( localplayer.rb.v )*1.0f;
+ state->grind_y_start = localplayer.rb.co[1];
+ }
+
+ if( state->activity >= k_skate_activity_grind_any ){
+ f32 dy = localplayer.rb.co[1] - state->grind_y_start;
+ if( dy < 0.0f ){
+ state->velocity_limit += -dy*0.2f;
+ }
+ state->grind_y_start = localplayer.rb.co[1];
+
+
+ f32 speed_end = v3_length( localplayer.rb.v );
+ if( speed_end > state->velocity_limit ){
+ v3_muls( localplayer.rb.v, state->velocity_limit/speed_end,
+ localplayer.rb.v );
+ }
+ }
}
static void player__skate_im_gui(void){
animator->grind_balance = vg_lerpf( animator->grind_balance, grind_frame,
5.0f*vg.time_delta );
+ animator->activity = state->activity;
/* pushing */
animator->push_time = vg.time - state->start_push;
}
else q_identity( animator->qfixuptotal );
rb_extrapolate( &localplayer.rb, animator->root_co, animator->root_q );
+ v3_copy( localplayer.rb.v, animator->root_v );
}
static void player__skate_pose( void *_animator, player_pose *pose ){
}
}
+static void player__skate_effects( void *_animator, m4x3f *final_mtx,
+ struct player_board *board,
+ struct player_effects_data *effect_data ){
+
+ struct skeleton *sk = &localplayer.skeleton;
+ struct player_skate_animator *animator = _animator;
+
+ if( animator->grind > 0.5f ){
+ v3f vp0, vp1, vpc;
+ if( board ){
+ v3_copy((v3f){0.0f,0.02f, board->truck_positions[0][2]}, vp1 );
+ v3_copy((v3f){0.0f,0.02f, board->truck_positions[1][2]}, vp0 );
+ }
+ else{
+ v3_zero( vp0 );
+ v3_zero( vp1 );
+ }
+
+ v3f *board_mtx = final_mtx[ localplayer.id_board ];
+ m4x3_mulv( board_mtx, vp0, vp0 );
+ m4x3_mulv( board_mtx, vp1, vp1 );
+ v3_add( vp0, vp1, vpc );
+ v3_muls( vpc, 0.5f, vpc );
+
+ int back = 0, front = 0, mid = 0;
+
+ if( animator->activity == k_skate_activity_grind_5050 ){
+ back = 1;
+ front = 1;
+ }
+ else if( animator->activity == k_skate_activity_grind_back50 ){
+ back = 1;
+ }
+ else if( animator->activity == k_skate_activity_grind_front50 ){
+ front = 1;
+ }
+ else if( animator->activity == k_skate_activity_grind_boardslide ){
+ mid = 1;
+ }
+
+ if( back ){
+ effect_spark_apply( &effect_data->spark, vp0,
+ animator->root_v, vg.time_delta );
+ }
+
+ if( front ){
+ effect_spark_apply( &effect_data->spark, vp1,
+ animator->root_v, vg.time_delta );
+ }
+
+ if( mid ){
+ effect_spark_apply( &effect_data->spark, vpc,
+ animator->root_v, vg.time_delta );
+ }
+ }
+}
+
static void player__skate_post_animate(void){
struct player_skate_state *state = &player_skate.state;
localplayer.cam_velocity_influence = 1.0f;
bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->push_time );
bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->jump_time );
+ bitpack_qv3f( ctx, 16, -100.0f, 100.0f, animator->root_v );
+ bitpack_bytes( ctx, 1, &animator->activity );
}
static void player__skate_sfx_oneshot( u8 id, v3f pos, f32 volume ){