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; i<len; i++ )
- {
+ for( int i=0; i<len; i++ ){
man[i].rba = &player->rb;
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 );
m3x3_mul( gate->transport, basis, basis );
if( gate->flags & k_ent_gate_nonlocal ){
- trace_world = &world_static.worlds[ gate->target ];
+ trace_world = &world_static.instances[ gate->target ];
}
}
}
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 );
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;
}
return;
}
- enum trick_type trick = k_trick_type_none;
- if( (s->state.activity <= k_skate_activity_air_to_grind) &&
- (trick = player_skate_trick_input( player )) )
- {
- if( (vg.time - s->state.jump_time) < 0.1f ){
- v3_zero( s->state.trick_vel );
- s->state.trick_time = 0.0f;
-
- if( trick == k_trick_type_kickflip ){
- s->state.trick_vel[0] = 3.0f;
- }
- else if( trick == k_trick_type_shuvit ){
- s->state.trick_vel[2] = 3.0f;
- }
- else if( trick == k_trick_type_treflip ){
- s->state.trick_vel[0] = 2.0f;
- s->state.trick_vel[2] = 2.0f;
+ if( s->state.activity <= k_skate_activity_air_to_grind ){
+ enum trick_type trick = k_trick_type_none;
+ if( (trick = player_skate_trick_input( player )) ){
+ if( (vg.time - s->state.jump_time) < 0.1f ){
+ v3_zero( s->state.trick_vel );
+ s->state.trick_time = 0.0f;
+
+ if( trick == k_trick_type_kickflip ){
+ s->state.trick_vel[0] = 3.0f;
+ }
+ else if( trick == k_trick_type_shuvit ){
+ s->state.trick_vel[2] = 3.0f;
+ }
+ else if( trick == k_trick_type_treflip ){
+ s->state.trick_vel[0] = 2.0f;
+ s->state.trick_vel[2] = 2.0f;
+ }
+ s->state.trick_type = trick;
}
- s->state.trick_type = trick;
}
}
+ else
+ s->state.trick_type = k_trick_type_none;
}
VG_STATIC void player__skate_post_update( 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;
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;
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;
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 );
}
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 );
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; i<l; i ++ )
/* counter-rotation */
if( v3_length2( s->state.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;
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 ) );
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 );
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 );
}
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;
}
/*
q_normalize( kf_wheels[i]->q );
}
+#if 0
{
mdl_keyframe
*kf_head = &pose->keyframes[av->id_head-1],
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 )