X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_glide.c;h=3091e57e2173c123c37206ad8eb6a10492102046;hb=171b279a489f1b906265759b33249f61d48d3d5f;hp=3ec1fac58ad9266c0e697d7fb716fb60f1dec208;hpb=f0ba02684dbf4722afa2dcfd491d56921162182a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_glide.c b/player_glide.c index 3ec1fac..3091e57 100644 --- a/player_glide.c +++ b/player_glide.c @@ -60,8 +60,7 @@ static void calculate_drag( v3f vl, f32 cd, v3f out_force ){ } static void player_glide_update(void){ - rigidbody *rb = &localplayer.rb; - vg_line_sphere( rb->to_world, 1.0f, 0 ); + rigidbody *rb = &player_glide.rb; v2f steer; joystick_state( k_srjoystick_steer, steer ); @@ -116,11 +115,68 @@ static void player_glide_update(void){ m3x3_mulv( rb->to_world, Fw, Fw ); v3_muladds( rb->w, Fw, k_rb_delta, rb->w ); + /* + * collisions & constraints + */ + world_instance *world = world_current_instance(); + rb_solver_reset(); + + rigidbody _null = {0}; + _null.inv_mass = 0.0f; + m3x3_zero( _null.iI ); + for( u32 i=0; i < vg_list_size(player_glide.parts); i ++ ){ + m4x3f mmdl; + m4x3_mul( rb->to_world, player_glide.parts[i].mdl, mmdl ); + + if( player_glide.parts[i].shape == k_rb_shape_capsule ){ + vg_line_capsule( mmdl, + player_glide.parts[i].inf.r, + player_glide.parts[i].inf.h, + VG__BLACK ); + } + else if( player_glide.parts[i].shape == k_rb_shape_sphere ){ + vg_line_sphere( mmdl, player_glide.parts[i].r, 0 ); + } + + if( rb_global_has_space() ){ + rb_ct *buf = rb_global_buffer(); + + u32 l = 0; + + if( player_glide.parts[i].shape == k_rb_shape_capsule ){ + l = rb_capsule__scene( mmdl, &player_glide.parts[i].inf, + NULL, world->geo_bh, buf, + k_material_flag_ghosts ); + } + else if( player_glide.parts[i].shape == k_rb_shape_sphere ){ + l = rb_sphere__scene( mmdl, player_glide.parts[i].r, + NULL, world->geo_bh, buf, + k_material_flag_ghosts ); + } + + for( u32 j=0; j