X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_skate.c;h=2ebcee2448668cbdcd0152c5c5b98a537e414069;hb=4fa1c611e0af4c32cdcc891f8c511217a2762d65;hp=df54c58e02fbe411734b7e38ce8dddd70f4899e1;hpb=1cc9e11790a81a4a5e3e4797afca35fc2eaa8c69;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_skate.c b/player_skate.c index df54c58..2ebcee2 100644 --- a/player_skate.c +++ b/player_skate.c @@ -394,15 +394,18 @@ void player__approximate_best_trajectory( player_instance *player ) v3_copy( launch_v, p->v ); + m3x3f basis; + m3x3_copy( player->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, player->basis[1], -0.5f * gravity * t*t, co1 ); + v3_muladds( co1, basis[1], -0.5f * gravity * t*t, co1 ); v3_add( launch_co, co1, co1 ); - float launch_vy = v3_dot( launch_v,player->basis[1] ); + float launch_vy = v3_dot( launch_v,basis[1] ); if( !grind_located && (launch_vy - gravity*t < 0.0f) ) { v3f closest; @@ -410,15 +413,15 @@ void player__approximate_best_trajectory( player_instance *player ) { v3f ve; v3_copy( launch_v, ve ); - v3_muladds( ve, player->basis[1], -gravity * t, ve ); + v3_muladds( ve, basis[1], -gravity * t, ve ); if( skate_grind_scansq( player, closest, ve, 0.5f, &grind ) ) { /* check alignment */ - v2f v0 = { v3_dot( ve, player->basis[0] ), - v3_dot( ve, player->basis[2] ) }, - v1 = { v3_dot( grind.dir, player->basis[0] ), - v3_dot( grind.dir, player->basis[2] ) }; + 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] ) }; v2_normalize( v0 ); v2_normalize( v1 ); @@ -433,6 +436,17 @@ void player__approximate_best_trajectory( player_instance *player ) } } + if( world->rendering_gate ){ + ent_gate *gate = world->rendering_gate; + if( gate_intersect( gate, co1, co0 ) ){ + m4x3_mulv( gate->transport, co0, co0 ); + 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 ); + } + } + float t1; v3f n;