X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_gen.h;h=5120bd758fe6e2ff09c7ec6ce5051fdba5b756fc;hb=2673c575386c604fc2c0603dba2480eda05cf97a;hp=38d2b6677ed366e43368d0c63e41927908335226;hpb=919d1227839218c57430fe9cab8f74d594c7bd14;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_gen.h b/world_gen.h index 38d2b66..5120bd7 100644 --- a/world_gen.h +++ b/world_gen.h @@ -126,92 +126,6 @@ VG_STATIC void world_apply_procedural_foliage( world_instance *world, vg_info( "%d foliage models added\n", count ); } -#if 0 -VG_STATIC void world_ents_allocate( world_instance *world ) -{ - vg_info( "Allocating entities\n" ); - - /* --count entites to allocate buffers for them.-- - * --maybe in the future we just store these numbers in the model file...-- - * - * ... 16.03.23: I HOPE YOUR FUCKING HAPPY - * ... 22.03.23: incomprehensible pain - * - * -- use this in world_routes too -- - * - */ - - struct countable - { - enum classtype ct, ct1; - void **to_allocate; - u32 item_size; - int count; - } - entity_counts[] = - { - { - k_classtype_spawn, - k_classtype_none, - (void*)&world->spawns, - sizeof(struct respawn_point) - }, - { - k_classtype_audio, - k_classtype_none, - (void*)&world->audio_things, - sizeof(struct world_audio_thing) - }, - { - k_classtype_world_light, - k_classtype_none, - (void*)&world->lights, - sizeof(struct world_light) - }, - { - k_classtype_nonlocal_gate, - k_classtype_none, - (void*)&world->nonlocal_gates, - sizeof(struct nonlocal_gate) - }, - }; - - for( int i=0; imeta->info.node_count; i++ ) - { - mdl_node *pnode = mdl_node_from_id( world->meta, i ); - - for( int j=0; jclasstype == entity_counts[j].ct) || - (pnode->classtype == entity_counts[j].ct1) ) - { - pnode->sub_uid = entity_counts[j].count; - entity_counts[j].count ++; - break; - } - } - } - - for( int i=0; iitem_size*counter->count; - *counter->to_allocate = vg_linear_alloc( world_global.generic_heap, - bufsize ); - memset( *counter->to_allocate, 0, bufsize ); - } - - world->volume_bh = bh_create( world_global.generic_heap, - &bh_system_volumes, - world, - world->volume_count, - 1 ); -} -#endif #if 0 VG_STATIC void world_pct_spawn( world_instance *world, mdl_node *pnode ) @@ -223,19 +137,6 @@ VG_STATIC void world_pct_spawn( world_instance *world, mdl_node *pnode ) rp->name = mdl_pstr( world->meta, pnode->pstr_name ); } -VG_STATIC void world_pct_water( world_instance *world, mdl_node *pnode ) -{ - if( world->water.enabled ) - { - vg_warn( "Multiple water surfaces in level! ('%s')\n", - mdl_pstr( world->meta, pnode->pstr_name )); - return; - } - - world->water.enabled = 1; - water_set_surface( world, pnode->co[1] ); -} - VG_STATIC void world_pct_audio( world_instance *world, mdl_node *pnode ) { struct world_audio_thing *thing = &world->audio_things[ @@ -875,17 +776,22 @@ VG_STATIC void world_unload( world_instance *world ) mesh_free( &world->mesh_route_lines ); mesh_free( &world->mesh_geo ); mesh_free( &world->mesh_no_collide ); - + + /* glDeleteBuffers silently ignores 0's and names that do not correspond to + * existing buffer objects. + * */ glDeleteBuffers( 1, &world->tbo_light_entities ); glDeleteTextures( 1, &world->tex_light_entities ); glDeleteTextures( 1, &world->tex_light_cubes ); /* FIXME: CANT DO THIS HERE */ + /* whynot? */ + /* oh this should be moved to a global function */ 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_route_board = 0; + world_global.sfd.active_route_board = 0; /* delete textures and meshes */ glDeleteTextures( world->texture_count, world->textures ); @@ -897,7 +803,6 @@ VG_STATIC void world_unload( world_instance *world ) vg_linear_clear( world->audio_vgl ); #endif - vg_release_thread_sync(); } @@ -906,8 +811,11 @@ VG_STATIC void world_clean( world_instance *world ) memset( &world->meta, 0, sizeof(mdl_context) ); /* - * TODO: Theres probably a better way to do this? - */ + * TODO: Theres probably a better way to do this? */ + /* yep, find all members that can be memsetted to 0. this is probably + * every member anyway, given the below is just setting to 0 + * + * also: rename clean to init? */ world->textures = NULL; world->texture_count = 0; @@ -921,6 +829,7 @@ VG_STATIC void world_clean( world_instance *world ) world->geo_bh = NULL; world->volume_bh = NULL; world->audio_bh = NULL; + world->rendering_gate = NULL; world->water.enabled = 0; @@ -966,6 +875,18 @@ VG_STATIC void world_entities_init( world_instance *world ) ent_gate *gate = mdl_arritm( &world->ent_gate, j ); gate_transform_update( gate ); } + + /* water */ + for( u32 j=0; jent_water); j++ ){ + ent_water *water = mdl_arritm( &world->ent_water, j ); + if( world->water.enabled ){ + vg_warn( "Multiple water surfaces in level!\n" ); + break; + } + + world->water.enabled = 1; + water_set_surface( world, water->transform.co[1] ); + } } VG_STATIC void world_load( world_instance *world, const char *path ) @@ -996,6 +917,8 @@ VG_STATIC void world_load( world_instance *world, const char *path ) "ent_checkpoint", world_global.generic_heap ); mdl_load_array( &world->meta, &world->ent_route, "ent_route", world_global.generic_heap ); + mdl_load_array( &world->meta, &world->ent_water, + "ent_water", world_global.generic_heap ); mdl_close( &world->meta );