ray_hit *ray = &samples[ sample_count ];
ray->dist = 2.0f;
- if( ray_world( world, pos, ray_dir, ray ) )
- {
+ if( ray_world( world, pos, ray_dir, ray, 0 ) ){
vg_line( pos, ray->pos, VG__RED );
vg_line_point( ray->pos, 0.025f, VG__BLACK );
ray_hit ray;
ray.dist = k_board_length*2.0f + 0.6f;
- if( ray_world( world, va, v0, &ray ) )
- {
+ if( ray_world( world, va, v0, &ray, 0 ) ){
vg_line( va, vb, VG__RED );
vg_line_point( ray.pos, 0.1f, VG__RED );
vg_error( "invalidated\n" );
}
v3_muls( v0, -1.0f, v0 );
- if( ray_world( world, vb, v0, &ray ) )
- {
+ if( ray_world( world, vb, v0, &ray, 0 ) ){
vg_line( va, vb, VG__RED );
vg_line_point( ray.pos, 0.1f, VG__RED );
vg_error( "invalidated\n" );
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; i<len; i++ ){
+ rb_ct *ci = &man[i];
+ if( ci->type == k_contact_type_disabled ||
+ ci->type == k_contact_type_edge )
+ continue;
+
+
+ float d1 = v3_dot( ci->co, ci->n );
+
+ for( int j=0; j<len; j++ ){
+ if( j == i )
+ continue;
+
+ rb_ct *cj = &man[j];
+ if( cj->type == 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 );
*/
len = rb_capsule__scene( mtx, &w->collider, NULL,
- &world->rb_geo.inf.scene, manifold );
- rb_manifold_filter_coplanar( manifold, len, 0.01f );
+ &world->rb_geo.inf.scene, manifold, 0 );
+ 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 };
v3f n;
float t;
- if( spherecast_world( world, pa, pb, w->collider.radius, &t, n ) != -1 ){
+ if( spherecast_world( world, pa, pb,
+ w->collider.radius, &t, n, 0 ) != -1 ){
if( player_walk_normal_standable( player, n ) ){
v3_lerp( pa, pb, t, player->rb.co );
v3_muladds( player->rb.co, player->basis[1],
float t, sr = w->collider.radius-0.04f;
v3f n;
- if( spherecast_world( world, lwr_prev, lwr_now, sr, &t, n ) != -1 ){
+ if( spherecast_world( world, lwr_prev, lwr_now, sr, &t, n, 0 ) != -1 ){
v3_lerp( lwr_prev, lwr_now, vg_maxf(0.01f,t), player->rb.co );
player->rb.co[1] -= w->collider.radius;
rb_update_transform( &player->rb );
v3_add( player->rb.co, player->basis[1], mtx[3] );
- vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__RED );
+ vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__RED);
}
}
int walk_phase = 0;
- if( vg_fractf(w->walk_timer) > 0.5f )
+ if( vg_fractf(w->state.walk_timer) > 0.5f )
walk_phase = 1;
else
walk_phase = 0;
- if( (w->step_phase != walk_phase) &&
+ if( (w->state.step_phase != walk_phase) &&
(w->state.activity == k_walk_activity_ground ) )
{
audio_lock();
audio_unlock();
}
- w->step_phase = walk_phase;
+ w->state.step_phase = walk_phase;
}
VG_STATIC void player__walk_animate( player_instance *player ){
run_norm = 30.0f/(float)w->anim_run->length,
walk_adv = vg_lerpf( walk_norm, run_norm, w->move_speed );
- w->walk_timer += walk_adv * vg.time_delta;
- }
- else{
- w->walk_timer = 0.0f;
+ w->state.walk_timer += walk_adv * vg.time_delta;
}
+ else
+ w->state.walk_timer = 0.0f;
+ animator->walk_timer = w->state.walk_timer;
if( !player->immobile )
rb_extrapolate( &player->rb, animator->root_co, animator->root_q );
v3_copy( animator->root_co, pose->root_co );
v4_copy( animator->root_q, pose->root_q );
pose->board.lean = 0.0f;
+ pose->type = k_player_pose_type_ik;
float walk_norm = (float)w->anim_walk->length/30.0f,
run_norm = (float)w->anim_run->length/30.0f,
- t = w->walk_timer,
+ t = animator->walk_timer,
l = vg_clampf( animator->run*15.0f, 0.0f, 1.0f ),
idle_walk = vg_clampf( (animator->run-0.1f)/(1.0f-0.1f), 0.0f, 1.0f );
VG_STATIC void player__walk_transition( player_instance *player ){
struct player_walk *w = &player->_walk;
w->state.activity = k_walk_activity_air;
+ w->state.outro_type = k_walk_outro_none;
+ w->state.outro_start_time = 0.0;
+ w->state.jump_queued = 0;
+ w->state.jump_input_time = 0.0;
+ w->state.walk_timer = 0.0f;
+ w->state.step_phase = 0;
v3f fwd = { 0.0f, 0.0f, 1.0f };
q_mulv( player->rb.q, fwd, fwd );