/* Physics */
rigidbody temp_rbs[128];
u32 rb_count;
- bh_tree bhcubes;
/* Rendering & geometry */
- scene geo, foliage, props;
- mdl_submesh sm_surface, sm_other;
+ scene geo, foliage;
+
+ mdl_submesh sm_geo_std_oob, sm_geo_std, sm_geo_vb;
glmesh skybox, skydome;
mdl_submesh dome_upper, dome_lower;
glmesh cars;
mdl_submesh car_holden;
+
+ rigidbody mr_ball;
}
world;
static int ray_hit_is_ramp( ray_hit *hit )
{
- return hit->tri[0] < world.sm_surface.vertex_count;
+ return hit->tri[0] > world.sm_geo_std_oob.vertex_count;
}
static void world_register(void)
world.traffic_count = 0;
scene_init( &world.geo );
- scene_init( &world.props );
/*
* Compile meshes into the world scenes
mat_vertex_blend = i;
}
- if( mat_surf )
- add_all_if_material( &world.geo, mworld, mat_surf );
- if( mat_vertex_blend )
- add_all_if_material( &world.geo, mworld, mat_vertex_blend );
-
-
- scene_copy_slice( &world.geo, &world.sm_surface );
-
if( mat_surf_oob )
add_all_if_material( &world.geo, mworld, mat_surf_oob );
else
vg_warn( "No OOB surface\n" );
+ scene_copy_slice( &world.geo, &world.sm_geo_std_oob );
- scene_bh_create( &world.geo );
- scene_upload( &world.geo );
+ if( mat_surf )
+ add_all_if_material( &world.geo, mworld, mat_surf );
+ scene_copy_slice( &world.geo, &world.sm_geo_std );
if( mat_vertex_blend )
- add_all_if_material( &world.props, mworld, mat_vertex_blend );
+ add_all_if_material( &world.geo, mworld, mat_vertex_blend );
+ scene_copy_slice( &world.geo, &world.sm_geo_vb );
- /* TODO bvh? */
+ scene_upload( &world.geo );
+ scene_bh_create( &world.geo );
/*
* Process entities
for( int i=0; i<vg_list_size(world.van_man); i++ )
world.van_man[i].current =&world.traffic[vg_randint(world.traffic_count)];
- scene_upload( &world.props );
-
- bh_create( &world.bhcubes,
- &bh_system_rigidbodies, world.temp_rbs, world.rb_count );
-
world_apply_foliage();
free( mworld );
winfo->g_water_fog = 0.04f;
render_update_lighting_ub();
+
+
+ world.mr_ball.type = k_rb_shape_sphere;
+ world.mr_ball.inf.sphere.radius = 2.0f;
+ v3_copy( (v3f){ 0.0f, 110.0f, 0.0f }, world.mr_ball.co );
+ q_identity(world.mr_ball.q);
+ rb_init( &world.mr_ball );
}
static void world_init(void)
static void world_update(void)
{
+ rb_solver_reset();
+ rb_build_manifold_terrain_sphere( &world.mr_ball );
+
+ for( int i=0; i<5; i++ )
+ rb_solve_contacts( rb_contact_buffer, rb_contact_count );
+
+ rb_iter( &world.mr_ball );
+ rb_update_transform( &world.mr_ball );
+ rb_debug( &world.mr_ball, 0 );
+
for( int i=0; i<vg_list_size(world.van_man); i++ )
{
traffic_drive( &world.van_man[i] );
vg_tex2d_bind( &tex_terrain_colours, 1 );
}
-static void render_props( m4x4f projection, v3f camera )
+static void render_world_vb( m4x4f projection, v3f camera )
{
m4x3f identity_matrix;
m4x3_identity( identity_matrix );
shader_vblend_uMdl( identity_matrix );
shader_vblend_uCamera( camera );
- scene_bind( &world.props );
- scene_draw( &world.props );
+ scene_bind( &world.geo );
+ mdl_draw_submesh( &world.sm_geo_vb );
mesh_bind( &world.cars );
shader_terrain_uCamera( camera );
scene_bind( &world.geo );
- scene_draw( &world.geo );
+ mdl_draw_submesh( &world.sm_geo_std_oob );
+ mdl_draw_submesh( &world.sm_geo_std );
glDisable(GL_CULL_FACE);
scene_bind( &world.foliage );
static void render_world( m4x4f projection, m4x3f camera )
{
render_sky( camera );
- render_props( projection, camera[3] );
+ render_world_vb( projection, camera[3] );
render_terrain( projection, camera[3] );
}
scene_draw( &world.foliage );
glEnable(GL_CULL_FACE);
#endif
-
- scene_bind( &world.props );
- scene_draw( &world.props );
}
#endif /* WORLD_H */