+ if( wheels[i].state == k_collider_state_disabled )
+ continue;
+
+ v3f truck, left, right;
+ m4x3_mulv( player->rb.to_world, wheels[i].pos, truck );
+ v3_muladds( truck, player->rb.to_world[0], -k_board_width, left );
+ v3_muladds( truck, player->rb.to_world[0], k_board_width, right );
+
+ vg_line( left, right, wheels[i].colour );
+
+ v3_muladds( left, player->rb.to_world[1], 0.1f, left );
+ v3_muladds( right, player->rb.to_world[1], 0.1f, right );
+
+ float k_max_truck_flex = VG_PIf * 0.25f;
+
+ ray_hit ray_l, ray_r;
+ ray_l.dist = 0.2f;
+ ray_r.dist = 0.2f;
+
+ v3f dir;
+ v3_muls( player->rb.to_world[1], -1.0f, dir );
+
+ int res_l = ray_world( left, dir, &ray_l ),
+ res_r = ray_world( right, dir, &ray_r );
+
+ /* ignore bad normals */
+ if( res_l )
+ {
+ if( v3_dot( ray_l.normal, player->rb.to_world[1] ) < 0.7071f )
+ res_l = 0;
+ else
+ v3_add( ray_l.normal, surface_picture, surface_picture );
+ }
+
+ if( res_r )
+ {
+ if( v3_dot( ray_r.normal, player->rb.to_world[1] ) < 0.7071f )
+ res_r = 0;
+ else
+ v3_add( ray_r.normal, surface_picture, surface_picture );
+ }
+
+ v3f v0;
+ v3f midpoint;
+ v3_muladds( truck, player->rb.to_world[1], -wheels[i].radius, midpoint );
+
+ if( res_l || res_r )
+ {
+ v3f p0, p1;
+ v3_copy( midpoint, p0 );
+ v3_copy( midpoint, p1 );
+
+ if( res_l ) v3_copy( ray_l.pos, p0 );
+ if( res_r ) v3_copy( ray_r.pos, p1 );
+
+ v3_sub( p1, p0, v0 );
+ v3_normalize( v0 );
+ }
+ else
+ {
+ /* fallback: use the closes point to the trucks */
+ v3f closest;
+ int idx = bh_closest_point( world.geo_bh, midpoint, closest, 0.1f );
+
+ if( idx != -1 )
+ {
+ u32 *tri = &world.scene_geo->arrindices[ idx * 3 ];
+ v3f verts[3];
+
+ for( int j=0; j<3; j++ )
+ v3_copy( world.scene_geo->arrvertices[ tri[j] ].co, verts[j] );
+
+ v3f vert0, vert1, n;
+ v3_sub( verts[1], verts[0], vert0 );
+ v3_sub( verts[2], verts[0], vert1 );
+ v3_cross( vert0, vert1, n );
+ v3_normalize( n );
+
+ if( v3_dot( n, player->rb.to_world[1] ) < 0.3f )
+ continue;
+
+ v3_cross( n, player->rb.to_world[2], v0 );
+ v3_muladds( v0, player->rb.to_world[2],
+ -v3_dot( player->rb.to_world[2], v0 ), v0 );
+ v3_normalize( v0 );
+ }
+ else
+ continue;
+ }
+
+ v3_muladds( truck, v0, k_board_width, right );
+ v3_muladds( truck, v0, -k_board_width, left );
+
+ vg_line( left, right, VG__WHITE );
+
+ rb_effect_spring_target_vector( &player->rb, player->rb.to_world[0], v0,
+ k_board_spring, k_board_dampener,
+ s->substep_delta );