v3f launch_v_bounds[2];
- for( int i=0; i<2; i++ ){
+ for( int i=0; i<2; i++ )
+ {
v3_copy( localplayer.rb.v, launch_v_bounds[i] );
float ang = (float[]){ angle_begin, angle_end }[ i ];
ang *= 0.15f;
q_mulv( qbias, launch_v_bounds[i], launch_v_bounds[i] );
}
- for( int m=0;m<=30; m++ ){
- jump_info *inf =
- &player_skate.possible_jumps[ player_skate.possible_jump_count ++ ];
+ for( int m=0;m<=30; m++ )
+ {
+ jump_info *inf = &player_skate.possible_jumps[ player_skate.possible_jump_count ++ ];
reset_jump_info( inf );
v3f launch_co, launch_v, co0, co1;
v3_copy( launch_v, v );
v3_copy( launch_co, co1 );
- for( int i=1; i<=50; i++ ){
+ for( int i=1; i<=50; i++ )
+ {
f32 t = (f32)i * k_trace_delta;
/* integrate forces */
/* 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 ){
+ 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;
v3f bound[2];
- for( int j=0; j<2; j++ ){
+ for( int j=0; j<2; j++ )
+ {
v3_muls( launch_v_bounds[j], t, bound[j] );
bound[j][1] += -0.5f*gravity*t*t;
v3_add( launch_co, bound[j], bound[j] );
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) ){
+ if( (closest[1] < minh) || (closest[1] > maxh) )
+ {
search_for_grind = 0;
}
}
search_for_grind = 0;
}
- if( search_for_grind ){
- if( skate_grind_scansq( closest, v, 0.5f, &grind ) ){
+ if( search_for_grind )
+ {
+ if( skate_grind_scansq( closest, v, 0.5f, &grind ) )
+ {
/* check alignment */
v2f v0 = { v[0], v[2] },
v1 = { grind.dir[0], grind.dir[2] };
}
}
- if( trace_world->rendering_gate ){
+ if( trace_world->rendering_gate )
+ {
ent_gate *gate = trace_world->rendering_gate;
- if( gate_intersect( gate, co1, co0 ) ){
+ if( gate_intersect( gate, co1, co0 ) )
+ {
m4x3_mulv( gate->transport, co0, co0 );
m4x3_mulv( gate->transport, co1, co1 );
m3x3_mulv( gate->transport, launch_v, launch_v);
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,
- k_material_flag_walking );
- if( idx != -1 ){
+ 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 );
v3_copy( co, inf->log[ inf->log_length ++ ] );
* --------------------------------------------------------------------------
*/
- for( int i=0; i<k_wheel_count; i++ ){
+ for( int i=0; i<k_wheel_count; i++ )
+ {
if( wheels[i].state == k_collider_state_disabled )
continue;
v3_muladds( localplayer.rb.to_world[3], localplayer.rb.to_world[1],
grind_radius + k_board_radius*0.25f+state->slap, mtx[3] );
+ /* board capsule */
rb_ct *cman = &manifold[manifold_len];
-
- int l = rb_capsule__scene( mtx, &capsule, NULL, world->geo_bh,
- cman, k_material_flag_walking );
-
+ int l = rb_capsule__scene( mtx, &capsule, NULL, world->geo_bh, cman, k_material_flag_walking );
/* weld joints */
for( int i=0; i<l; i ++ )
cman[l].type = k_contact_type_edge;
rb_manifold_filter_joint_edges( cman, l, 0.03f );
l = rb_manifold_apply_filtered( cman, l );
-
manifold_len += l;
- vg_line_capsule( mtx, capsule.r, capsule.h, VG__WHITE );
+
+ /* props */
+ for( u32 i=0; i<af_arrcount( &world->ent_prop ); i ++ )
+ {
+ ent_prop *prop = af_arritm( &world->ent_prop, i );
+ if( prop->flags & k_prop_flag_hidden )
+ continue;
+
+ if( prop->flags & k_prop_flag_collider )
+ {
+ f32 box_r = v3_length( prop->transform.s ),
+ player_r = 2.0f,
+ min_dist = box_r + player_r,
+ min_dist2 = min_dist*min_dist;
+
+ if( v3_dist2( localplayer.rb.co, prop->transform.co ) < min_dist2 )
+ {
+ m4x3f mmdl, mmdl_inv;
+ q_m3x3( prop->transform.q, mmdl );
+ v3_copy( prop->transform.co, mmdl[3] );
+ m4x3_invert_affine( mmdl, mmdl_inv );
+
+ boxf box;
+ v3_negate( prop->transform.s, box[0] );
+ v3_copy( prop->transform.s, box[1] );
+ manifold_len += rb_sphere__box( localplayer.rb.co, 1.0f, mmdl, mmdl_inv, box, manifold+manifold_len );
+
+ vg_line_boxf_transformed( mmdl, box, 0xffffff00 );
+ }
+ }
+ }
/* add limits */
- if( state->activity >= k_skate_activity_grind_any ){
- for( int i=0; i<state->limit_count; i++ ){
+ if( state->activity >= k_skate_activity_grind_any )
+ {
+ for( int i=0; i<state->limit_count; i++ )
+ {
struct grind_limit *limit = &state->limits[i];
rb_ct *ct = &manifold[ manifold_len ++ ];
m4x3_mulv( localplayer.rb.to_world, limit->ra, ct->co );
}
}
+ vg_line_capsule( mtx, capsule.r, capsule.h, VG__WHITE );
+
/*
* Phase 3: Dynamics
* --------------------------------------------------------------------------
v3f world_cog;
- m4x3_mulv( localplayer.rb.to_world,
- state->weight_distribution, world_cog );
+ m4x3_mulv( localplayer.rb.to_world, state->weight_distribution, world_cog );
vg_line_point( world_cog, 0.02f, VG__BLACK );
- for( int i=0; i<manifold_len; i ++ ){
+ for( int i=0; i<manifold_len; i ++ )
+ {
rb_prepare_contact( &manifold[i], player_skate.substep_delta );
rb_debug_contact( &manifold[i] );
}
m3x3_mul( iI, localplayer.rb.to_local, iIw );
m3x3_mul( localplayer.rb.to_world, iIw, iIw );
- for( int j=0; j<10; j++ ){
- for( int i=0; i<manifold_len; i++ ){
+ for( int j=0; j<10; j++ )
+ {
+ for( int i=0; i<manifold_len; i++ )
+ {
/*
* regular dance; calculate velocity & total mass, apply impulse.
*/