X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_walk.c;h=3cefc295068cf8ff5b4cd666663ee2e4b7ad5ba4;hb=8a31c1ffcb632b9b6d1702332f0d75d609c0a87b;hp=87c2246fe6960a662852f3210d95abfc8e1c062d;hpb=188685bc8454ff40b733d9e9df8da45e3c2e2c39;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_walk.c b/player_walk.c index 87c2246..3cefc29 100644 --- a/player_walk.c +++ b/player_walk.c @@ -370,6 +370,43 @@ VG_STATIC void player_friction( v3f v ){ v3_muls( v, newspeed, v ); } +VG_STATIC void player_walk_custom_filter( world_instance *world, + rb_ct *man, int len, f32 w ){ + for( int i=0; itype == k_contact_type_disabled || + ci->type == k_contact_type_edge ) + continue; + + + float d1 = v3_dot( ci->co, ci->n ); + + for( int j=0; jtype == k_contact_type_disabled ) + continue; + + struct world_surface *si = world_contact_surface( world, ci ), + *sj = world_contact_surface( world, cj ); + + if( (sj->info.flags & k_material_flag_walking) && + !(si->info.flags & k_material_flag_walking)){ + continue; + } + + float d2 = v3_dot( cj->co, ci->n ), + d = d2-d1; + + if( fabsf( d ) <= w ){ + cj->type = k_contact_type_disabled; + } + } + } +} + VG_STATIC void player__walk_update( player_instance *player ){ struct player_walk *w = &player->_walk; v3_copy( player->rb.co, w->state.prev_pos ); @@ -421,7 +458,7 @@ VG_STATIC void player__walk_update( player_instance *player ){ len = rb_capsule__scene( mtx, &w->collider, NULL, &world->rb_geo.inf.scene, manifold ); - rb_manifold_filter_coplanar( manifold, len, 0.01f ); + player_walk_custom_filter( world, manifold, len, 0.01f ); len = rb_manifold_apply_filtered( manifold, len ); v3f surface_avg = { 0.0f, 0.0f, 0.0f };