X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world.h;h=9242023a31d7ffade26696bfecb3ee9eec52b876;hb=344f0153cf1907da87dd041db3ec517325b1c429;hp=add08b7c30d1180a1125a8a4c9a10dd2c9102c5e;hpb=6d66c67945f84476d6ac75a0497007cc30bcf58c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world.h b/world.h index add08b7..9242023 100644 --- a/world.h +++ b/world.h @@ -48,17 +48,19 @@ static struct gworld /* 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; @@ -81,7 +83,7 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit ) 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) @@ -179,7 +181,6 @@ static void world_load(void) world.traffic_count = 0; scene_init( &world.geo ); - scene_init( &world.props ); /* * Compile meshes into the world scenes @@ -203,26 +204,22 @@ static void world_load(void) 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 @@ -317,11 +314,6 @@ static void world_load(void) for( int i=0; ig_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) @@ -406,6 +405,16 @@ 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