- /*
- * TODO: World settings entity
- */
- struct ub_world_lighting *winfo = &gpipeline.ub_world_lighting;
- v4_copy( wrender.plane, winfo->g_water_plane );
-
- v4f bounds;
- bounds[0] = world.geo.bbx[0][0];
- bounds[1] = world.geo.bbx[0][2];
- bounds[2] = 1.0f/ (world.geo.bbx[1][0]-world.geo.bbx[0][0]);
- bounds[3] = 1.0f/ (world.geo.bbx[1][2]-world.geo.bbx[0][2]);
- v4_copy( bounds, winfo->g_depth_bounds );
-
- winfo->g_water_fog = 0.04f;
- render_update_lighting_ub();
+#if 0
+ /*
+ * Setup scene collider
+ */
+ reset_player( 1, (const char *[]){"start"} );
+#endif
+}
+
+VG_STATIC void world_process_resources( world_instance *world )
+{
+ vg_info( "Loading textures\n" );
+ world->texture_count = world->meta->info.texture_count;
+ world->textures = vg_linear_alloc( world_global.generic_heap,
+ sizeof(GLuint)*world->texture_count );
+
+ vg_acquire_thread_sync();
+ {
+ /* error texture */
+ world->textures[0] = vg_tex2d_new();
+ vg_tex2d_set_error();
+ vg_tex2d_nearest();
+ vg_tex2d_repeat();
+
+ for( int i=1; i<world->texture_count; i++ )
+ {
+ mdl_texture *tex = &world->meta->texture_buffer[i];
+
+ if( !tex->pack_offset )
+ {
+ vg_release_thread_sync();
+ vg_fatal_exit_loop( "World models must have packed textures!" );
+ }
+
+ vg_linear_clear( vg_mem.scratch );
+ world->textures[i] = vg_tex2d_new();
+ vg_tex2d_set_error();
+ vg_tex2d_qoi( world->meta->pack + tex->pack_offset, tex->pack_length,
+ mdl_pstr( world->meta, tex->pstr_name ));
+ vg_tex2d_nearest();
+ vg_tex2d_repeat();
+ }
+ }
+ vg_release_thread_sync();
+
+ vg_info( "Loading materials\n" );
+
+ u32 size = sizeof(struct world_material) * world->meta->info.material_count;
+ world->materials = vg_linear_alloc( world_global.generic_heap, size );
+
+ world->material_count = world->meta->info.material_count;
+ memset( world->materials, 0, size );
+
+ for( int i=1; i<world->material_count; i++ )
+ world->materials[i].info = world->meta->material_buffer[i];
+
+ /* error material */
+ struct world_material *errmat = &world->materials[0];
+ v4_copy( (v4f){ 1.0f,0.0f,0.0f,1.0f }, errmat->info.colour );
+ v4_copy( (v4f){ 1.0f,0.0f,0.0f,1.0f }, errmat->info.colour1 );
+ errmat->info.flags = 0x00;
+ errmat->info.pstr_name = 0; /* useless? */
+ errmat->info.shader = -1;
+ errmat->info.tex_decal = 0;
+ errmat->info.tex_diffuse = 0;
+ errmat->info.tex_normal = 0;
+}
+
+VG_STATIC void world_unload( world_instance *world )
+{
+ vg_acquire_thread_sync();
+
+ /* free meshes */
+ mesh_free( &world->mesh_route_lines );
+ mesh_free( &world->mesh_geo );
+ mesh_free( &world->mesh_no_collide );
+
+ /* FIXME: CANT DO THIS HERE */
+ world_global.time = 0.0;
+ world_global.rewind_from = 0.0;
+ world_global.rewind_to = 0.0;
+ world_global.last_use = 0.0;
+ world_global.active_gate = 0;
+ world_global.current_run_version = 2;
+ world_global.active_route_board = 0;
+
+ for( int i=0; i<vg_list_size(world_global.ui_bars); i++ )
+ {
+ struct route_ui_bar *uib = &world_global.ui_bars[i];
+ uib->segment_start = 0;
+ uib->segment_count = 0;
+ uib->fade_start = 0;
+ uib->fade_count = 0;
+ uib->fade_timer_start = 0.0;
+ uib->xpos = 0.0f;