X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_skate.c;h=1aba17a7646535b9c6c01a78759dd5085b771985;hb=f965094faed4f1828c7a6a6b3ca856bd5f1e5248;hp=9356aa6416b04e54e73fdec941157509699ca597;hpb=284dd9f21b28acb957eb6f16ef48f4f9527daa54;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_skate.c b/player_skate.c index 9356aa6..1aba17a 100644 --- a/player_skate.c +++ b/player_skate.c @@ -9,10 +9,13 @@ #include "addon.h" #include "ent_tornado.c" +#include "vg/vg_rigidbody.h" +#include "scene_rigidbody.h" +#include "player_glide.h" static void player__skate_bind(void){ struct skeleton *sk = &localplayer.skeleton; - rb_update_transform( &localplayer.rb ); + rb_update_matrices( &localplayer.rb ); struct { struct skeleton_anim **anim; const char *name; } bindings[] = { @@ -61,11 +64,11 @@ static void player__skate_kill_audio(void){ * Does collision detection on a sphere vs world, and applies some smoothing * filters to the manifold afterwards */ -static int skate_collide_smooth( m4x3f mtx, rb_sphere *sphere, rb_ct *man ){ +static int skate_collide_smooth( m4x3f mtx, f32 r, rb_ct *man ){ world_instance *world = world_current_instance(); int len = 0; - len = rb_sphere__scene( mtx, sphere, NULL, &world->rb_geo.inf.scene, man, + len = rb_sphere__scene( mtx, r, NULL, world->geo_bh, man, k_material_flag_walking ); for( int i=0; itrick_vel) >= 0.0001f ) && state->trick_time > 0.2f) { + vg_info( "player fell off due to lack of skill\n" ); player__dead_transition( k_player_die_type_feet ); } @@ -1146,7 +1150,7 @@ static void skate_integrate(void){ localplayer.rb.w ); state->flip_time += state->flip_rate * k_rb_delta; - rb_update_transform( &localplayer.rb ); + rb_update_matrices( &localplayer.rb ); } static enum trick_type player_skate_trick_input(void){ @@ -1209,7 +1213,7 @@ static void player__skate_pre_update(void){ m3x3_q( transfer, qtransfer ); q_mul( qtransfer, state->store_smoothed, state->smoothed_rotation ); q_normalize( state->smoothed_rotation ); - rb_update_transform( &localplayer.rb ); + rb_update_matrices( &localplayer.rb ); if( end ){ state->activity = k_skate_activity_air; @@ -1219,6 +1223,13 @@ static void player__skate_pre_update(void){ if( button_down(k_srbind_use) && (v3_length2(state->trick_vel) < 0.01f) ){ localplayer.subsystem = k_player_subsystem_walk; + + if( (state->activity <= k_skate_activity_air_to_grind) && + localplayer.have_glider ){ + player_glide_transition(); + return; + } + v3f angles; v3_copy( localplayer.cam.angles, localplayer.angles ); localplayer.angles[2] = 0.0f; @@ -2198,6 +2209,7 @@ static void player__skate_update(void){ if( world->water.enabled ){ if( localplayer.rb.co[1]+0.25f < world->water.height ){ + vg_info( "player fell off due to being in water\n" ); player__networked_sfx( k_player_subsystem_walk, 32, k_player_walk_soundeffect_splash, localplayer.rb.co, 1.0f ); @@ -2459,7 +2471,7 @@ begin_collision:; v3_add( localplayer.rb.co, cg_offset, localplayer.rb.co ); } - rb_update_transform( &localplayer.rb ); + rb_update_matrices( &localplayer.rb ); localplayer.rb.v[1] += -state->gravity_bias * player_skate.substep_delta; player_skate.substep -= player_skate.substep_delta; @@ -2479,8 +2491,9 @@ begin_collision:; k_material_flag_walking ) != -1) ) { v3_lerp( start_co, localplayer.rb.co, t, localplayer.rb.co ); - rb_update_transform( &localplayer.rb ); + rb_update_matrices( &localplayer.rb ); + vg_info( "player fell of due to hitting head\n" ); player__dead_transition( k_player_die_type_head ); return; } @@ -2497,12 +2510,10 @@ begin_collision:; m4x3f mtx; m3x3_identity( mtx ); m4x3_mulv( localplayer.rb.to_world, wheels[i].pos, mtx[3] ); - - rb_sphere collider = { .radius = wheels[i].radius }; rb_ct *man = &manifold[ manifold_len ]; - int l = skate_collide_smooth( mtx, &collider, man ); + int l = skate_collide_smooth( mtx, wheels[i].radius, man ); if( l ) wheels[i].state = k_collider_state_colliding; @@ -2510,8 +2521,8 @@ begin_collision:; } float grind_radius = k_board_radius * 0.75f; - rb_capsule capsule = { .height = (k_board_length+0.2f)*2.0f, - .radius=grind_radius }; + rb_capsule capsule = { .h = (k_board_length+0.2f)*2.0f, + .r = grind_radius }; m4x3f mtx; v3_muls( localplayer.rb.to_world[0], 1.0f, mtx[0] ); v3_muls( localplayer.rb.to_world[2], -1.0f, mtx[1] ); @@ -2521,7 +2532,7 @@ begin_collision:; rb_ct *cman = &manifold[manifold_len]; - int l = rb_capsule__scene( mtx, &capsule, NULL, &world->rb_geo.inf.scene, + int l = rb_capsule__scene( mtx, &capsule, NULL, world->geo_bh, cman, k_material_flag_walking ); /* weld joints */ @@ -2531,9 +2542,7 @@ begin_collision:; l = rb_manifold_apply_filtered( cman, l ); manifold_len += l; - - if( vg_lines.draw ) - vg_line_capsule( mtx, capsule.radius, capsule.height, VG__WHITE ); + vg_line_capsule( mtx, capsule.r, capsule.h, VG__WHITE ); /* add limits */ if( state->activity >= k_skate_activity_grind_any ){ @@ -2594,7 +2603,7 @@ begin_collision:; * regular dance; calculate velocity & total mass, apply impulse. */ - struct contact *ct = &manifold[i]; + rb_ct *ct = &manifold[i]; v3f rv, delta; v3_sub( ct->co, world_cog, delta ); @@ -2633,7 +2642,7 @@ begin_collision:; v3f dt; rb_depenetrate( manifold, manifold_len, dt ); v3_add( dt, localplayer.rb.co, localplayer.rb.co ); - rb_update_transform( &localplayer.rb ); + rb_update_matrices( &localplayer.rb ); substep_count ++; @@ -2648,6 +2657,7 @@ begin_collision:; f32 nforce = v3_length(normal_total); if( nforce > 4.0f ){ if( nforce > 17.6f ){ + vg_info( "player fell off due to hitting ground too hard\n" ); v3_muladds( localplayer.rb.v, normal_total, -1.0f, localplayer.rb.v ); player__dead_transition( k_player_die_type_feet ); return; @@ -2703,7 +2713,9 @@ begin_collision:; q_mul( transport_rotation, localplayer.rb.q, localplayer.rb.q ); q_mul( transport_rotation, state->smoothed_rotation, state->smoothed_rotation ); - rb_update_transform( &localplayer.rb ); + q_normalize( localplayer.rb.q ); + q_normalize( state->smoothed_rotation ); + rb_update_matrices( &localplayer.rb ); player__pass_gate( id ); } @@ -3493,6 +3505,7 @@ static void player__skate_effects( void *_animator, m4x3f *final_mtx, static void player__skate_post_animate(void){ struct player_skate_state *state = &player_skate.state; localplayer.cam_velocity_influence = 1.0f; + localplayer.cam_dist = 1.8f; v3f head = { 0.0f, 1.8f, 0.0f }; m4x3_mulv( localplayer.final_mtx[ localplayer.id_head ],