v4f q;
q_axis_angle( q, localplayer.rb.to_world[1], a );
- q_mulv( q, player_skate.grind_vec, player_skate.grind_vec );
+ q_mulv( q, state->grind_vec, state->grind_vec );
- v3_normalize( player_skate.grind_vec );
+ v3_normalize( state->grind_vec );
}
else if( state->manual_direction ){
float tilt = steer[0] * 0.3f;
tilt *= vg_signf(v3_dot( localplayer.rb.v,
- player_skate.grind_dir ));
+ state->grind_dir ));
v4f qtilt;
- q_axis_angle( qtilt, player_skate.grind_dir, tilt );
+ q_axis_angle( qtilt, state->grind_dir, tilt );
q_mulv( qtilt, jumpdir, jumpdir );
}
state->surface_cooldown = 10;
else{
#if 0
float a = v3_dot( localplayer.rb.to_world[2],
- player_skate.grind_dir );
+ state->grind_dir );
if( fabsf(a) > 0.70710678118654752f )
sample_type = k_skate_sample_concrete_scrape_wood;
else
static void skate_weight_distribute(void){
struct player_skate_state *state = &player_skate.state;
- v3_zero( player_skate.weight_distribution );
+ v3_zero( state->weight_distribution );
int reverse_dir = v3_dot( localplayer.rb.to_world[2],
localplayer.rb.v ) < 0.0f?1:-1;
if( state->manual_direction ){
float amt = vg_minf( steer[1] * 8.0f, 1.0f );
- player_skate.weight_distribution[2] = k_board_length * amt *
+ state->weight_distribution[2] = k_board_length * amt *
(float)state->manual_direction;
}
if( state->manual_direction ){
v3f plane_z;
- m3x3_mulv( localplayer.rb.to_world, player_skate.weight_distribution,
+ m3x3_mulv( localplayer.rb.to_world, state->weight_distribution,
plane_z );
v3_negate( plane_z, plane_z );
- v3_muladds( plane_z, player_skate.surface_picture,
- -v3_dot( plane_z, player_skate.surface_picture ), plane_z );
+ v3_muladds( plane_z, state->surface_picture,
+ -v3_dot( plane_z, state->surface_picture ), plane_z );
v3_normalize( plane_z );
- v3_muladds( plane_z, player_skate.surface_picture, 0.3f, plane_z );
+ v3_muladds( plane_z, state->surface_picture, 0.3f, plane_z );
v3_normalize( plane_z );
v3f p1;
if( state->activity == k_skate_activity_ground ){
v3f target;
- v3_copy( player_skate.surface_picture, target );
+ v3_copy( state->surface_picture, target );
- target[1] += 2.0f * player_skate.surface_picture[1];
+ target[1] += 2.0f * state->surface_picture[1];
v3_normalize( target );
v3_lerp( state->up_dir, target,
m3x3_mulv( localplayer.rb.to_world, ra, raw );
v3_add( localplayer.rb.co, raw, wsp );
- v3_copy( ra, player_skate.weight_distribution );
+ v3_copy( ra, state->weight_distribution );
v3f delta;
v3_sub( inf->co, wsp, delta );
m3x3f mtx;
skate_grind_orient( inf, mtx );
v3f target_fwd, fwd, up, target_up;
- m3x3_mulv( mtx, player_skate.grind_vec, target_fwd );
+ m3x3_mulv( mtx, state->grind_vec, target_fwd );
v3_copy( raw_nplane, fwd );
v3_copy( localplayer.rb.to_world[1], up );
v3_copy( inf->n, target_up );
vg_line_arrow( localplayer.rb.co, fwd, 0.8f, VG__RED );
vg_line_arrow( localplayer.rb.co, target_fwd, 1.0f, VG__YELOW );
- player_skate.grind_strength = strength;
-
/* Fake contact */
struct grind_limit *limit =
- &player_skate.limits[ player_skate.limit_count ++ ];
+ &state->limits[ state->limit_count ++ ];
m4x3_mulv( localplayer.rb.to_local, wsp, limit->ra );
m3x3_mulv( localplayer.rb.to_local, inf->n, limit->n );
limit->p = 0.0f;
- v3_copy( inf->dir, player_skate.grind_dir );
+ v3_copy( inf->dir, state->grind_dir );
}
static void skate_5050_apply( struct grind_info *inf_front,
q_axis_angle( q, localplayer.rb.to_world[0], VG_PIf*0.25f * -way );
q_mulv( q, target_up, target_up );
- v3_zero( player_skate.weight_distribution );
- player_skate.weight_distribution[2] = k_board_length * -way;
+ v3_zero( state->weight_distribution );
+ state->weight_distribution[2] = k_board_length * -way;
rb_effect_spring_target_vector( &localplayer.rb, up, target_up,
k_grind_spring,
/* Fake contact */
struct grind_limit *limit =
- &player_skate.limits[ player_skate.limit_count ++ ];
+ &state->limits[ state->limit_count ++ ];
v3_zero( limit->ra );
m3x3_mulv( localplayer.rb.to_local, inf_avg.n, limit->n );
limit->p = 0.0f;
- v3_copy( inf_avg.dir, player_skate.grind_dir );
+ v3_copy( inf_avg.dir, state->grind_dir );
}
static int skate_grind_truck_renew( f32 sign, struct grind_info *inf ){
if( dv < minv )
return 0;
- if( fabsf(v3_dot( inf->dir, player_skate.grind_dir )) < k_grind_max_edge_angle )
+ if( fabsf(v3_dot( inf->dir, state->grind_dir )) < k_grind_max_edge_angle )
return 0;
- v3_copy( inf->dir, player_skate.grind_dir );
+ v3_copy( inf->dir, state->grind_dir );
return 1;
}
v3f intersection;
v3_muladds( local_co, local_dir, local_co[0]/-local_dir[0],
intersection );
- v3_copy( intersection, player_skate.weight_distribution );
+ v3_copy( intersection, state->weight_distribution );
skate_grind_decay( inf, 0.0125f );
skate_grind_friction( inf, 0.25f );
vg_line_arrow( localplayer.rb.co, dir, 0.5f, VG__GREEN );
vg_line_arrow( localplayer.rb.co, perp, 0.5f, VG__BLUE );
- v3_copy( inf->dir, player_skate.grind_dir );
+ v3_copy( inf->dir, state->grind_dir );
}
static int skate_boardslide_entry( struct grind_info *inf ){
if( dv < minv )
return 0;
- if( fabsf(v3_dot( inf->dir, player_skate.grind_dir )) < k_grind_max_edge_angle )
+ if( fabsf(v3_dot( inf->dir, state->grind_dir )) < k_grind_max_edge_angle )
return 0;
return 1;
v3f raw;
v3_sub( inf->co, localplayer.rb.co, raw );
- m3x3_mulv( mtx, raw, player_skate.grind_vec );
- v3_normalize( player_skate.grind_vec );
- v3_copy( inf->dir, player_skate.grind_dir );
+ m3x3_mulv( mtx, raw, state->grind_vec );
+ v3_normalize( state->grind_vec );
+ v3_copy( inf->dir, state->grind_dir );
}
static enum skate_activity skate_availible_grind(void){
player_skate.substep = vg.time_fixed_delta;
player_skate.substep_delta = player_skate.substep;
- player_skate.limit_count = 0;
+ state->limit_count = 0;
int substep_count = 0;
- v3_zero( player_skate.surface_picture );
+ v3_zero( state->surface_picture );
int prev_contacts[2];
k_surface_spring, k_surface_dampener,
player_skate.substep_delta );
- v3_add( normal, player_skate.surface_picture,
- player_skate.surface_picture );
+ v3_add( normal, state->surface_picture,
+ state->surface_picture );
contact_count ++;
player_skate.wheel_contacts[i] = 1;
}
if( contact_count ){
state->activity = k_skate_activity_ground;
state->gravity_bias = k_gravity;
- v3_normalize( player_skate.surface_picture );
+ v3_normalize( state->surface_picture );
skate_apply_friction_model();
skate_weight_distribute();
if( state->activity > k_skate_activity_air_to_grind )
state->activity = k_skate_activity_air;
- v3_zero( player_skate.weight_distribution );
+ v3_zero( state->weight_distribution );
skate_apply_air_model();
}
v4_copy( localplayer.rb.q, future_q );
v3f future_cg, current_cg, cg_offset;
- q_mulv( localplayer.rb.q, player_skate.weight_distribution, current_cg );
- q_mulv( future_q, player_skate.weight_distribution, future_cg );
+ q_mulv( localplayer.rb.q, state->weight_distribution, current_cg );
+ q_mulv( future_q, state->weight_distribution, future_cg );
v3_sub( future_cg, current_cg, cg_offset );
/* calculate the minimum time we can move */
q_mul( rotation, localplayer.rb.q, localplayer.rb.q );
q_normalize( localplayer.rb.q );
- q_mulv( localplayer.rb.q, player_skate.weight_distribution, future_cg );
+ q_mulv( localplayer.rb.q, state->weight_distribution, future_cg );
v3_sub( current_cg, future_cg, cg_offset );
v3_add( localplayer.rb.co, cg_offset, localplayer.rb.co );
}
/* add limits */
if( state->activity >= k_skate_activity_grind_any ){
- for( int i=0; i<player_skate.limit_count; i++ ){
- struct grind_limit *limit = &player_skate.limits[i];
+ for( int i=0; i<state->limit_count; i++ ){
+ struct grind_limit *limit = &state->limits[i];
rb_ct *ct = &manifold[ manifold_len ++ ];
m4x3_mulv( localplayer.rb.to_world, limit->ra, ct->co );
m3x3_mulv( localplayer.rb.to_world, limit->n, ct->n );
v3f world_cog;
m4x3_mulv( localplayer.rb.to_world,
- player_skate.weight_distribution, world_cog );
+ state->weight_distribution, world_cog );
vg_line_point( world_cog, 0.02f, VG__BLACK );
for( int i=0; i<manifold_len; i ++ ){
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;
+ wdist= state->weight_distribution[2] / k_board_length;
if( state->activity >= k_skate_activity_grind_any )
wdist = 0.0f;
state->surface_cooldown = 0;
v3_muladds( localplayer.rb.co, localplayer.rb.to_world[1], 1.0f, state->cog );
v3_copy( localplayer.rb.to_world[1], state->up_dir );
- v3_copy( localplayer.rb.to_world[1], player_skate.surface_picture );
+ v3_copy( localplayer.rb.to_world[1], state->surface_picture );
v3_copy( localplayer.rb.co, state->prev_pos );
- v3_zero( player_skate.weight_distribution );
+ v3_zero( state->weight_distribution );
v3f head = { 0.0f, 1.8f, 0.0f };
m4x3_mulv( localplayer.rb.to_world, head, state->head_position );