- float launch_vy = v3_dot( launch_v,player->basis[1] );
- if( !grind_located && (launch_vy - gravity*t < 0.0f) )
- {
- v3f closest;
- if( bh_closest_point( world->geo_bh, co1, closest, 1.0f ) != -1 )
- {
- v3f ve;
- v3_copy( launch_v, ve );
- v3_muladds( ve, player->basis[1], -gravity * t, ve );
-
- if( skate_grind_scansq( player, closest, ve, 0.5f, &grind ) )
- {
- /* check alignment */
- v2f v0 = { v3_dot( ve, player->basis[0] ),
- v3_dot( ve, player->basis[2] ) },
- v1 = { v3_dot( grind.dir, player->basis[0] ),
- v3_dot( grind.dir, player->basis[2] ) };
+ float launch_vy = v3_dot( launch_v,basis[1] );
+
+ int search_for_grind = 1;
+ if( grind_located ) search_for_grind = 0;
+ if( launch_vy - gravity*t > 0.0f ) search_for_grind = 0;
+
+ /* REFACTOR */
+
+ v3f closest={0.0f,0.0f,0.0f};
+ if( search_for_grind ){
+ if( bh_closest_point(trace_world->geo_bh,co1,closest,1.0f) != -1 ){
+ float min_dist = 0.75f;
+ min_dist *= min_dist;
+
+ if( v3_dist2( closest, launch_co ) < min_dist )
+ search_for_grind = 0;
+
+ v3f bound[2];
+
+ for( int j=0; j<2; j++ ){
+ v3_muls( launch_v_bounds[j], t, bound[j] );
+ v3_muladds( bound[j], basis[1], -0.5f*gravity*t*t, bound[j] );
+ v3_add( launch_co, bound[j], bound[j] );
+ }
+
+ float limh = vg_minf( 2.0f, t ),
+ minh = vg_minf( bound[0][1], bound[1][1] )-limh,
+ maxh = vg_maxf( bound[0][1], bound[1][1] )+limh;
+
+ if( (closest[1] < minh) || (closest[1] > maxh) ){
+ search_for_grind = 0;
+ }
+ }
+ else
+ search_for_grind = 0;
+ }
+
+ if( search_for_grind ){
+ v3f ve;
+ v3_copy( launch_v, ve );
+ v3_muladds( ve, basis[1], -gravity * t, ve );
+
+ if( skate_grind_scansq( player, closest, ve, 0.5f, &grind ) ){
+ /* check alignment */
+ v2f v0 = { v3_dot( ve, basis[0] ),
+ v3_dot( ve, basis[2] ) },
+ v1 = { v3_dot( grind.dir, basis[0] ),
+ v3_dot( grind.dir, basis[2] ) };