X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_skate.c;h=522ea3010a3fd93cf909063e4f6be1397203c202;hb=874c9d7e6ee2d826f9eb34518e8163283439c38e;hp=74668282b51104bf70c52c6e3b110a94776a6d5b;hpb=7f4c71033c06954f3094c9d51219628438b80ac8;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_skate.c b/player_skate.c index 7466828..522ea30 100644 --- a/player_skate.c +++ b/player_skate.c @@ -117,7 +117,7 @@ static int skate_grind_scansq( v3f pos, v3f dir, float r, support_max; v3f support_axis; - v3_cross( plane, localplayer.basis[1], support_axis ); + v3_cross( plane, (v3f){0,1,0}, support_axis ); v3_normalize( support_axis ); bh_iter it; @@ -154,9 +154,9 @@ static int skate_grind_scansq( v3f pos, v3f dir, float r, v3_cross( va, vb, normal ); sample->normal[0] = v3_dot( support_axis, normal ); - sample->normal[1] = v3_dot( localplayer.basis[1], normal ); + sample->normal[1] = normal[1]; sample->co[0] = v3_dot( support_axis, d ); - sample->co[1] = v3_dot( localplayer.basis[1], d ); + sample->co[1] = d[1]; v3_copy( normal, sample->normal3 ); /* normalize later if we want to us it */ @@ -234,8 +234,8 @@ too_many_samples: v3_muls( dir, vg_signf(v3_dot(dir,plane)), dir ); v3_add( average_direction, dir, average_direction ); - float yi = v3_dot( localplayer.basis[1], si->normal3 ), - yj = v3_dot( localplayer.basis[1], sj->normal3 ); + float yi = si->normal3[1], + yj = sj->normal3[1]; if( yi > yj ) v3_add( si->normal3, average_normal, average_normal ); else v3_add( sj->normal3, average_normal, average_normal ); @@ -287,18 +287,14 @@ static int create_jumps_to_hit_target( jump_info *jumps, v3f v0; v3_sub( target, localplayer.rb.co, v0 ); - m3x3_mulv( localplayer.invbasis, v0, v0 ); v3f ax; v3_copy( v0, ax ); ax[1] = 0.0f; v3_normalize( ax ); - v3f v_local; - m3x3_mulv( localplayer.invbasis, localplayer.rb.v, v_local ); - - v2f d = { v3_dot( ax, v0 ), v0[1] }, - v = { v3_dot( ax, v_local ), v_local[1] }; + v2f d = { v3_dot( ax, v0 ), v0[1] }, + v = { v3_dot( ax, localplayer.rb.v ), localplayer.rb.v[1] }; float a = atan2f( v[1], v[0] ), m = v2_length( v ), @@ -317,7 +313,6 @@ static int create_jumps_to_hit_target( jump_info *jumps, v3_muls( ax, cosf( a0 ) * m, inf->v ); inf->v[1] += sinf( a0 ) * m; - m3x3_mulv( localplayer.basis, inf->v, inf->v ); inf->land_dist = d[0] / (cosf(a0)*m); inf->gravity = gravity; @@ -330,7 +325,6 @@ static int create_jumps_to_hit_target( jump_info *jumps, v3_muls( ax, cosf( a1 ) * m, inf->v ); inf->v[1] += sinf( a1 ) * m; - m3x3_mulv( localplayer.basis, inf->v, inf->v ); inf->land_dist = d[0] / (cosf(a1)*m); inf->gravity = gravity; @@ -358,7 +352,7 @@ static void player__approximate_best_trajectory(void){ v3_normalize( axis ); /* at high slopes, Y component is low */ - float upness = v3_dot( localplayer.rb.to_world[1], localplayer.basis[1] ), + float upness = localplayer.rb.to_world[1][1], angle_begin = -(1.0f-fabsf( upness )), angle_end = 1.0f; @@ -408,17 +402,14 @@ static void player__approximate_best_trajectory(void){ inf->gravity = gravity; v3_copy( launch_v, inf->v ); - m3x3f basis; - m3x3_copy( localplayer.basis, basis ); - for( int i=1; i<=50; i++ ){ float t = (float)i * k_trace_delta; v3_muls( launch_v, t, co1 ); - v3_muladds( co1, basis[1], -0.5f * gravity * t*t, co1 ); + co1[1] += -0.5f * gravity * t*t; v3_add( launch_co, co1, co1 ); - float launch_vy = v3_dot( launch_v,basis[1] ); + float launch_vy = launch_v[1]; int search_for_grind = 1; if( grind_located ) search_for_grind = 0; @@ -439,7 +430,7 @@ static void player__approximate_best_trajectory(void){ for( int j=0; j<2; j++ ){ v3_muls( launch_v_bounds[j], t, bound[j] ); - v3_muladds( bound[j], basis[1], -0.5f*gravity*t*t, bound[j] ); + bound[j][1] += -0.5f*gravity*t*t; v3_add( launch_co, bound[j], bound[j] ); } @@ -458,14 +449,12 @@ static void player__approximate_best_trajectory(void){ if( search_for_grind ){ v3f ve; v3_copy( launch_v, ve ); - v3_muladds( ve, basis[1], -gravity * t, ve ); + ve[1] += -gravity * t; if( skate_grind_scansq( closest, ve, 0.5f, &grind ) ){ /* check alignment */ - v2f v0 = { v3_dot( ve, basis[0] ), - v3_dot( ve, basis[2] ) }, - v1 = { v3_dot( grind.dir, basis[0] ), - v3_dot( grind.dir, basis[2] ) }; + v2f v0 = { ve[0], ve[2] }, + v1 = { grind.dir[0], grind.dir[2] }; v2_normalize( v0 ); v2_normalize( v1 ); @@ -494,7 +483,6 @@ static void player__approximate_best_trajectory(void){ m4x3_mulv( gate->transport, co1, co1 ); m3x3_mulv( gate->transport, launch_v, launch_v); m4x3_mulv( gate->transport, launch_co, launch_co ); - m3x3_mul( gate->transport, basis, basis ); } } @@ -520,7 +508,7 @@ static void player__approximate_best_trajectory(void){ v3f ve; v3_copy( launch_v, ve ); - v3_muladds( ve, localplayer.basis[1], -gravity * t, ve ); + ve[1] += -gravity * t; inf->score = -v3_dot( ve, inf->n ); inf->land_dist = t + k_trace_delta * t1; @@ -567,13 +555,10 @@ static void player__approximate_best_trajectory(void){ v3_copy( jump->v, launch_v ); v3_copy( localplayer.rb.co, launch_co ); - - m3x3f basis; - m3x3_copy( localplayer.basis, basis ); float t = 0.05f * jump->land_dist; v3_muls( launch_v, t, co0 ); - v3_muladds( co0, basis[1], -0.5f * jump->gravity * t*t, co0 ); + co0[1] += -0.5f * jump->gravity * t*t; v3_add( launch_co, co0, co0 ); /* rough scan to make sure we dont collide with anything */ @@ -584,7 +569,7 @@ static void player__approximate_best_trajectory(void){ t *= jump->land_dist; v3_muls( launch_v, t, co1 ); - v3_muladds( co1, basis[1], -0.5f * jump->gravity * t*t, co1 ); + co1[1] += -0.5f * jump->gravity * t*t; v3_add( launch_co, co1, co1 ); float t1; @@ -605,8 +590,7 @@ static void player__approximate_best_trajectory(void){ /* determine score */ v3f ve; v3_copy( jump->v, ve ); - v3_muladds( ve, localplayer.basis[1], - -jump->gravity*jump->land_dist, ve ); + ve[1] += -jump->gravity*jump->land_dist; jump->score = -v3_dot( ve, grind.n ) * 0.9f; player_skate.possible_jumps[ player_skate.possible_jump_count ++ ] = @@ -677,9 +661,8 @@ invalidated_grind:; v3_zero( state->flip_axis ); } } - else{ - v3_copy( localplayer.basis[1], state->land_normal ); - } + else + v3_copy( (v3f){0,1,0}, state->land_normal ); } /* @@ -939,7 +922,7 @@ static void skate_apply_jump_model(void){ v3f jumpdir; /* Launch more up if alignment is up else improve velocity */ - float aup = v3_dot( localplayer.basis[1], localplayer.rb.to_world[1] ), + float aup = localplayer.rb.to_world[1][1], mod = 0.5f, dir = mod + fabsf(aup)*(1.0f-mod); @@ -1049,9 +1032,7 @@ static void skate_apply_cog_model(void){ /* Apply forces & intergrate */ v3_muladds( state->cog_v, F, -rb, state->cog_v ); - v3_muladds( state->cog_v, localplayer.basis[1], -9.8f * k_rb_delta, - state->cog_v ); - + state->cog_v[1] += -9.8f * k_rb_delta; v3_muladds( state->cog, state->cog_v, k_rb_delta, state->cog ); } @@ -1497,7 +1478,7 @@ static void skate_adjust_up_direction(void){ } else{ v3f avg; - v3_add( localplayer.rb.to_world[1], localplayer.basis[1], avg ); + v3_add( localplayer.rb.to_world[1], (v3f){0,1,0}, avg ); v3_normalize( avg ); v3_lerp( state->up_dir, avg, @@ -2102,9 +2083,7 @@ static void player__skate_update(void){ } } min_dist -= 0.2f; - float vy = v3_dot( localplayer.basis[1], localplayer.rb.v ); - vy = vg_maxf( 0.0f, vy ); - + float vy = vg_maxf( 0.0f, localplayer.rb.v[1] ); slap = vg_clampf( (min_dist/0.5f) + vy, 0.0f, 1.0f )*0.3f; } state->slap = vg_lerpf( state->slap, slap, 10.0f*k_rb_delta ); @@ -2305,9 +2284,7 @@ begin_collision:; } rb_update_transform( &localplayer.rb ); - v3_muladds( localplayer.rb.v, localplayer.basis[1], - -state->gravity_bias * player_skate.substep_delta, - localplayer.rb.v ); + localplayer.rb.v[1] += -state->gravity_bias * player_skate.substep_delta; player_skate.substep -= player_skate.substep_delta;