X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_gen.h;h=4605adf662a6107c0a02b0b12c037a39f48f205d;hb=bdac014448b6ec968fe645f1581f321144f07dba;hp=40d6f4c9653c4473c58de098038ae2948cae9ee7;hpb=a64c18c5996fd5ac9601239f91b12275f04f9cd9;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_gen.h b/world_gen.h index 40d6f4c..4605adf 100644 --- a/world_gen.h +++ b/world_gen.h @@ -30,24 +30,6 @@ VG_STATIC void world_add_all_if_material( m4x3f transform, scene *pscene, scene_add_submesh( pscene, mdl, sm, transform2 ); } } - -#if 0 - if( pnode->classtype == k_classtype_instance ) - { - if( pnode->sub_uid ) - { - u32 instance_id = pnode->sub_uid -1; - struct instance_cache *cache = &world.instance_cache[instance_id]; - mdl_context *mdl2 = cache->mdl; - - m4x3f transform2; - mdl_node_transform( pnode, transform2 ); - m4x3_mul( transform, transform2, transform2 ); - - world_add_all_if_material( transform2, pscene, mdl2, id ); - } - } -#endif } } @@ -198,51 +180,6 @@ VG_STATIC void world_pct_water( mdl_node *pnode ) } } -VG_STATIC void world_pct_instance( mdl_node *pnode ) -{ - struct classtype_instance *inst = mdl_get_entdata( world.meta, pnode ); - pnode->sub_uid = 0; - - int cache_entry = 0; - for( int i=0; ipstr_file == cache->pstr_file ) - { - cache_entry = 1; - pnode->sub_uid = i+1; - break; - } - } - - if( !cache_entry ) - { - if( world.instance_cache_count == vg_list_size(world.instance_cache) ) - vg_fatal_exit_loop( "Instance cache is full!" ); - - struct instance_cache *cache = - &world.instance_cache[world.instance_cache_count ++ ]; - - cache->pstr_file = inst->pstr_file; - -#if 0 - cache->mdl = mdl_load( filename ); - - if( cache->mdl ) - { - world.instance_cache_count ++; - pnode->sub_uid = world.instance_cache_count; - mdl_link_materials( mworld, cache->mdl ); - vg_success( "Cached %s\n", filename ); - } - else - { - vg_warn( "Failed to cache %s\n", filename ); - } -#endif - } -} - VG_STATIC void world_pct_audio( mdl_node *pnode ) { struct world_audio_thing *thing = &world.audio_things[ @@ -260,6 +197,8 @@ VG_STATIC void world_pct_audio( mdl_node *pnode ) thing->flags = aud->flags; thing->temp_embedded_clip.path = mdl_pstr( world.meta, aud->pstr_file ); + thing->temp_embedded_clip.source_mode = k_audio_source_mono; + audio_clip_load( &thing->temp_embedded_clip ); thing->player.name = mdl_pstr( world.meta, pnode->pstr_name ); thing->player.enqued = 0; @@ -279,7 +218,6 @@ VG_STATIC void world_entities_process(void) { { k_classtype_spawn, world_pct_spawn }, { k_classtype_water, world_pct_water }, - { k_classtype_instance, world_pct_instance }, { k_classtype_audio, world_pct_audio }, }; @@ -343,25 +281,12 @@ VG_STATIC void world_entities_process(void) #endif } -VG_STATIC void world_load_instance_cache(void) -{ - vg_linear_clear( vg_mem.scratch ); - - for( int i=0; ipstr_file ); - inst->mdl = mdl_load_full( vg_mem.scratch, filename ); - } -} - VG_STATIC void world_generate(void) { /* * Compile meshes into the world scenes */ - world.scene_geo = scene_init( world.dynamic_vgl, 500000, 1200000 ); + world.scene_geo = scene_init( world.dynamic_vgl, 350000, 1200000 ); /* * TODO: System to dynamically allocate these @@ -396,8 +321,6 @@ VG_STATIC void world_generate(void) m4x3f midentity; m4x3_identity( midentity ); - world_load_instance_cache(); - /* * Generate scene: collidable geometry * ---------------------------------------------------------------- @@ -464,6 +387,7 @@ VG_STATIC void world_generate(void) world.scene_no_collide = scene_init( world.dynamic_vgl, 200000, 500000 ); vg_info( "Applying foliage\n" ); + srand(0); world_apply_procedural_foliage(); scene_copy_slice( world.scene_no_collide, &world.sm_foliage_main ); @@ -613,13 +537,8 @@ VG_STATIC void world_unload(void) } /* delete the entire block of memory */ - memset( world.dynamic_vgl, 0xff, 72*1024*1024 ); - vg_linear_clear( world.dynamic_vgl ); - for( u32 i=0; i<72*1024*1024; i++ ) - ((u8 *)world.dynamic_vgl)[i] = 0xff^i; - /* clean dangling pointers */ world.meta = NULL; @@ -658,7 +577,6 @@ VG_STATIC void world_unload(void) world.collectors = NULL; world.collector_count = 0; - world.instance_cache_count = 0; world.water.enabled = 0; }