X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_skate.c;h=7da738ef6419013c0bff9dc460d94abc9bb62d47;hb=1d06671f87a9d24596fc6808d8e0db889a818750;hp=a7899075d0525f5db0a62a92f74aaf230bc5f4ea;hpb=188685bc8454ff40b733d9e9df8da45e3c2e2c39;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_skate.c b/player_skate.c index a789907..7da738e 100644 --- a/player_skate.c +++ b/player_skate.c @@ -59,18 +59,17 @@ VG_STATIC int skate_collide_smooth( player_instance *player, 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, sphere, NULL, &world->rb_geo.inf.scene, man, + k_material_flag_walking ); - for( int i=0; irb; man[i].rbb = NULL; } rb_manifold_filter_coplanar( man, len, 0.03f ); - if( len > 1 ) - { + if( len > 1 ){ rb_manifold_filter_backface( man, len ); rb_manifold_filter_joint_edges( man, len, 0.03f ); rb_manifold_filter_pairs( man, len, 0.03f ); @@ -511,7 +510,8 @@ void player__approximate_best_trajectory( player_instance *player ) float scan_radius = k_board_radius; scan_radius *= vg_clampf( t, 0.02f, 1.0f ); - int idx = spherecast_world(trace_world, co0, co1, scan_radius, &t1, n); + int idx = spherecast_world( trace_world, co0, co1, scan_radius, &t1, n, + k_material_flag_walking ); if( idx != -1 ){ v3f co; v3_lerp( co0, co1, t1, co ); @@ -598,7 +598,8 @@ void player__approximate_best_trajectory( player_instance *player ) v3f n; int idx = spherecast_world( world0, co0,co1, - k_board_radius*0.1f, &t1, n); + k_board_radius*0.1f, &t1, n, + k_material_flag_walking ); if( idx != -1 ){ goto invalidated_grind; } @@ -1332,7 +1333,7 @@ int skate_compute_surface_alignment( player_instance *player, v3_muladds( left, player->rb.to_world[1], k_board_radius, left ); ray_l.dist = 2.1f * k_board_radius; - res_l = ray_world( world, left, dir, &ray_l ); + res_l = ray_world( world, left, dir, &ray_l, k_material_flag_walking ); if( res_l ) break; @@ -1344,7 +1345,7 @@ int skate_compute_surface_alignment( player_instance *player, v3_muladds( right, player->rb.to_world[1], k_board_radius, right ); ray_r.dist = 2.1f * k_board_radius; - res_r = ray_world( world, right, dir, &ray_r ); + res_r = ray_world( world, right, dir, &ray_r, k_material_flag_walking ); if( res_r ) break; @@ -1511,7 +1512,8 @@ VG_STATIC int skate_point_visible( v3f origin, v3f target ){ v3_muls( dir, 1.0f/ray.dist, dir ); ray.dist -= 0.025f; - if( ray_world( world_current_instance(), origin, dir, &ray ) ) + if( ray_world( world_current_instance(), origin, dir, &ray, + k_material_flag_walking ) ) return 0; return 1; @@ -2282,7 +2284,8 @@ begin_collision:; v3f n; float cast_radius = wheels[i].radius - k_penetration_slop * 2.0f; - if( spherecast_world( world, current, future, cast_radius, &t, n ) != -1) + if( spherecast_world( world, current, future, cast_radius, &t, n, + k_material_flag_walking ) != -1) max_time = vg_minf( max_time, t * s->substep ); } @@ -2329,7 +2332,8 @@ begin_collision:; float t; v3f n; if( (v3_dist2( head_wp0, head_wp1 ) > 0.001f) && - (spherecast_world( world, head_wp0, head_wp1, 0.2f, &t, n ) != -1) ) + (spherecast_world( world, head_wp0, head_wp1, 0.2f, &t, n, + k_material_flag_walking ) != -1) ) { v3_lerp( start_co, player->rb.co, t, player->rb.co ); rb_update_transform( &player->rb ); @@ -2376,7 +2380,7 @@ begin_collision:; rb_ct *cman = &manifold[manifold_len]; int l = rb_capsule__scene( mtx, &capsule, NULL, &world->rb_geo.inf.scene, - cman ); + cman, k_material_flag_walking ); /* weld joints */ for( int i=0; istate.up_dir ) > 0.001f ){ - if( v4_length(s->state.smoothed_rotation) <= 0.1f || - v4_length(s->state.smoothed_rotation) >= 1.1f ){ - vg_warn( "FIX THIS! CARROT\n" ); /* this never happens anymore? */ - v4_copy( player->rb.q, s->state.smoothed_rotation ); - } v4_lerp( s->state.smoothed_rotation, player->rb.q, 2.0f*vg.time_frame_delta, s->state.smoothed_rotation ); q_normalize( s->state.smoothed_rotation ); - v3f yaw_ref = {1.0f,0.0f,0.0f}, - yaw_smooth = {1.0f,0.0f,0.0f}; - q_mulv( player->rb.q, yaw_ref, yaw_ref ); + v3f yaw_smooth = {1.0f,0.0f,0.0f}; q_mulv( s->state.smoothed_rotation, yaw_smooth, yaw_smooth ); m3x3_mulv( player->rb.to_local, yaw_smooth, yaw_smooth ); - m3x3_mulv( player->rb.to_local, yaw_ref, yaw_ref ); + yaw_smooth[1] = 0.0f; + v3_normalize( yaw_smooth ); - f32 yaw_counter_rotate = v3_dot(yaw_ref,yaw_smooth); - yaw_counter_rotate = vg_clampf(yaw_counter_rotate,-0.7f,0.7f); + f32 yaw_counter_rotate = yaw_smooth[0]; + yaw_counter_rotate = vg_maxf( 0.7f, yaw_counter_rotate ); yaw_counter_rotate = acosf( yaw_counter_rotate ); yaw_counter_rotate *= 1.0f-animator->fly; @@ -2878,7 +2876,6 @@ VG_STATIC void player__skate_animate( player_instance *player ){ v3_normalize( ndir ); v3f up = { 0.0f, 1.0f, 0.0f }; - float a = v3_dot( ndir, up ); a = acosf( vg_clampf( a, -1.0f, 1.0f ) ); @@ -2886,9 +2883,11 @@ VG_STATIC void player__skate_animate( player_instance *player ){ v4f qcounteryaw, qfixup; v3_cross( up, ndir, axis ); - q_axis_angle( qfixup, axis, a ); + q_axis_angle( qfixup, axis, a*2.0f ); + + v3_cross( (v3f){1.0f,0.0f,0.0f}, yaw_smooth, axis ); + q_axis_angle( qcounteryaw, axis, yaw_counter_rotate ); - q_axis_angle( qcounteryaw, (v3f){0.0f,1.0f,0.0f}, yaw_counter_rotate ); q_mul( qcounteryaw, qfixup, animator->qfixuptotal ); q_normalize( animator->qfixuptotal ); @@ -2896,11 +2895,10 @@ VG_STATIC void player__skate_animate( player_instance *player ){ m3x3_mulv( player->rb.to_world, up, p1 ); m3x3_mulv( player->rb.to_world, ndir, p2 ); - vg_line_arrow( player->rb.co, p1, 0.25f, VG__PINK ); - vg_line_arrow( player->rb.co, p2, 0.25f, VG__PINK ); + vg_line_arrow( player->rb.co, p1, 0.5f, VG__PINK ); + vg_line_arrow( player->rb.co, p2, 0.5f, VG__PINK ); } else q_identity( animator->qfixuptotal ); - q_identity( animator->qfixuptotal ); rb_extrapolate( &player->rb, animator->root_co, animator->root_q ); } @@ -3060,14 +3058,19 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ if( animator->trick_type == k_trick_type_kickflip ){ kf_foot_l->co[0] += animator->trick_foot * 0.2f; + kf_foot_l->co[1] -= animator->trick_foot * 0.18f; } else if( animator->trick_type == k_trick_type_shuvit ){ kf_foot_l->co[0] += animator->trick_foot * 0.1f; kf_foot_r->co[0] -= animator->trick_foot * 0.15f; + kf_foot_l->co[1] -= animator->trick_foot * 0.18f; + kf_foot_r->co[1] -= animator->trick_foot * 0.18f; } else if( animator->trick_type == k_trick_type_treflip ){ kf_foot_l->co[0] += animator->trick_foot * 0.2f; kf_foot_r->co[0] -= animator->trick_foot * 0.15f; + kf_foot_l->co[1] -= animator->trick_foot * 0.18f; + kf_foot_r->co[1] -= animator->trick_foot * 0.18f; } /* @@ -3088,6 +3091,7 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ q_normalize( kf_wheels[i]->q ); } +#if 0 { mdl_keyframe *kf_head = &pose->keyframes[av->id_head-1], @@ -3118,6 +3122,7 @@ VG_STATIC void player__skate_pose( player_instance *player, player_pose *pose ){ q_mul( qrot, kf_head->q, kf_head->q ); q_normalize( kf_head->q ); } +#endif } VG_STATIC void player__skate_post_animate( player_instance *player )