phys->reverse = -vg_signf(vel[2]);
float substep = VG_TIMESTEP_FIXED * 0.2f;
-
-#if 0
- float fwd_resistance = vg_get_button( "break" )? 5.0f: k_friction_resistance;
-#else
float fwd_resistance = k_friction_resistance;
-#endif
for( int i=0; i<5; i++ )
{
vel[2] -= new_vel * phys->reverse;
}
- /* Pumping */
- static float previous = 0.0f;
- float delta = previous - phys->grab,
- pump = delta * k_pump_force * VG_TIMESTEP_FIXED;
- previous = phys->grab;
-
- v3f p1;
- v3_muladds( phys->rb.co, phys->rb.up, pump, p1 );
- vg_line( phys->rb.co, p1, 0xff0000ff );
-
- vel[1] += pump;
-
m3x3_mulv( phys->rb.to_world, vel, phys->rb.v );
float input = player.input_js1h->axis.value,
}
}
+VG_STATIC void player_grind(void)
+{
+ struct player_phys *phys = &player.phys;
+
+ v3f closest;
+ int idx = bh_closest_point( world.grind_bh, phys->rb.co, closest, INFINITY );
+ if( idx == -1 )
+ return;
+
+ struct grind_edge *edge = &world.grind_edges[ idx ];
+
+ vg_line( phys->rb.co, closest, 0xff000000 );
+ vg_line_cross( closest, 0xff000000, 0.3f );
+ vg_line( edge->p0, edge->p1, 0xff000000 );
+
+ return;
+
+ idx = bh_closest_point( world.geo_bh, phys->rb.co, closest, INFINITY );
+ vg_line( phys->rb.co, closest, 0xff000000 );
+ vg_line_cross( closest, 0xff000000, 0.3f );
+
+ idx = world.scene_geo->arrindices[ idx * 3 ];
+ struct world_material *mat = world_tri_index_material( idx );
+
+ if( mat->info.flags & k_material_flag_grind_surface )
+ {
+ v3f grind_delta;
+ v3_sub( closest, phys->rb.co, grind_delta );
+
+ float p = v3_dot( phys->rb.forward, grind_delta );
+ v3_muladds( grind_delta, phys->rb.forward, -p, grind_delta );
+
+ float a = vg_maxf( 0.0f, 4.0f-v3_dist2( closest, phys->rb.co ) );
+ v3_muladds( phys->rb.v, grind_delta, a*0.2f, phys->rb.v );
+ }
+}
+
/*
* Physics collision detection, and control
*/
rb_debug( rbb, 0xffffff00 );
rb_ct manifold[64];
- int len = 0;
+ int len_f = 0,
+ len_b = 0;
- len += rb_sphere_scene( rbf, &world.rb_geo, manifold+len );
- len += rb_sphere_scene( rbb, &world.rb_geo, manifold+len );
+ len_f = rb_sphere_scene( rbf, &world.rb_geo, manifold );
+ rb_manifold_filter_coplanar( manifold, len_f, 0.05f );
+ if( len_f > 1 )
+ {
+ rb_manifold_filter_backface( manifold, len_f );
+ rb_manifold_filter_joint_edges( manifold, len_f, 0.05f );
+ rb_manifold_filter_pairs( manifold, len_f, 0.05f );
+ }
+ len_f = rb_manifold_apply_filtered( manifold, len_f );
+
+ rb_ct *man_b = &manifold[len_f];
+ len_b = rb_sphere_scene( rbb, &world.rb_geo, man_b );
+ rb_manifold_filter_coplanar( man_b, len_b, 0.05f );
+ if( len_b > 1 )
+ {
+ rb_manifold_filter_backface( man_b, len_b );
+ rb_manifold_filter_joint_edges( man_b, len_b, 0.05f );
+ rb_manifold_filter_pairs( man_b, len_b, 0.05f );
+ }
+ len_b = rb_manifold_apply_filtered( man_b, len_b );
+
+ int len = len_f+len_b;
+
+ player_grind();
+
+ boxf bax;
+ v3_sub( phys->rb.co, (v3f){2.0f,2.0f,2.0f}, bax[0] );
+ v3_add( phys->rb.co, (v3f){2.0f,2.0f,2.0f}, bax[1] );
/*
* Preprocess collision points, and create a surface picture.
if( !phys->in_air )
{
- /* 20/10/22: make this only go axisways instead, may effect velocities. */
-
v3f projected, axis;
float d = v3_dot( phys->rb.forward, surface_avg );