X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_walk.c;h=fbae15d4e1dc12b1c18bb21094d0dcdf645c89b6;hb=34a8df54eb962f3ad2e036355041f5bc5cabe5a0;hp=c86c9dba385d28ac8f3da4b0a22ad0013659c59b;hpb=3e8fda9c7cbc50d1ae95195905c953bdeedf71b9;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_walk.c b/player_walk.c index c86c9db..fbae15d 100644 --- a/player_walk.c +++ b/player_walk.c @@ -118,6 +118,7 @@ VG_STATIC void player_walk_drop_in_overhang_transform( player_instance *player, VG_STATIC int player_walk_scan_for_drop_in( player_instance *player ) { struct player_walk *w = &player->_walk; + world_instance *world = get_active_world(); v3f dir, center; q_mulv( player->rb.q, (v3f){0.0f,0.0f,1.0f}, dir ); @@ -140,7 +141,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player ) ray_hit *ray = &samples[ sample_count ]; ray->dist = 2.0f; - if( ray_world( pos, ray_dir, ray ) ) + if( ray_world( world, pos, ray_dir, ray ) ) { vg_line( pos, ray->pos, VG__RED ); vg_line_pt3( ray->pos, 0.025f, VG__BLACK ); @@ -218,7 +219,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player ) ray_hit ray; ray.dist = k_board_length*2.0f + 0.6f; - if( ray_world( va, v0, &ray ) ) + if( ray_world( world, va, v0, &ray ) ) { vg_line( va, vb, VG__RED ); vg_line_pt3( ray.pos, 0.1f, VG__RED ); @@ -227,7 +228,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player ) } v3_muls( v0, -1.0f, v0 ); - if( ray_world( vb, v0, &ray ) ) + if( ray_world( world, vb, v0, &ray ) ) { vg_line( va, vb, VG__RED ); vg_line_pt3( ray.pos, 0.1f, VG__RED ); @@ -395,8 +396,10 @@ VG_STATIC void player__walk_update( player_instance *player ) /* * Collision detection */ + world_instance *world = get_active_world(); + len = rb_capsule__scene( mtx, &w->collider, NULL, - &world.rb_geo.inf.scene, manifold ); + &world->rb_geo.inf.scene, manifold ); rb_manifold_filter_coplanar( manifold, len, 0.01f ); len = rb_manifold_apply_filtered( manifold, len ); @@ -458,7 +461,8 @@ VG_STATIC void player__walk_update( player_instance *player ) { player_friction( player->rb.v ); - struct world_material *surface_mat = world_contact_material(manifold); + struct world_material *surface_mat = + world_contact_material( world, manifold); w->surface = surface_mat->info.surface_prop; } } @@ -565,7 +569,7 @@ VG_STATIC void player__walk_update( player_instance *player ) float t, sr = w->collider.radius-0.04f; v3f n; - if( spherecast_world( lwr_prev, lwr_now, sr, &t, n ) != -1 ) + if( spherecast_world( world, lwr_prev, lwr_now, sr, &t, n ) != -1 ) { v3_lerp( lwr_prev, lwr_now, vg_maxf(0.01f,t), player->rb.co ); player->rb.co[1] -= w->collider.radius; @@ -576,9 +580,10 @@ VG_STATIC void player__walk_update( player_instance *player ) } } - teleport_gate *gate; - if( (gate = world_intersect_gates( player->rb.co, w->state.prev_pos )) ) + struct gate_hit hit; + if( world_intersect_gates(world, player->rb.co, w->state.prev_pos, &hit) ) { + teleport_gate *gate = hit.gate; m4x3_mulv( gate->transport, player->rb.co, player->rb.co ); m3x3_mulv( gate->transport, player->rb.v, player->rb.v ); @@ -589,7 +594,7 @@ VG_STATIC void player__walk_update( player_instance *player ) rb_update_transform( &player->rb ); w->state_gate_storage = w->state; - player__pass_gate( player, gate ); + player__pass_gate( player, &hit ); } }