X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_gen.h;h=cbf47287f9d1de2881a4a60de7b0287119281e74;hb=a9e3181f697ab37fc74f072cfcfdf44e2d659468;hp=293784aa5365d496e3a375326300d2d242525de1;hpb=0136a935c00e3ea1f231fd88b38b44982fd409ac;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_gen.h b/world_gen.h index 293784a..cbf4728 100644 --- a/world_gen.h +++ b/world_gen.h @@ -151,7 +151,7 @@ VG_STATIC void world_ents_allocate( world_instance *world ) struct countable { - enum classtype ct; + enum classtype ct, ct1; void **to_allocate; u32 item_size; int count; @@ -160,38 +160,54 @@ VG_STATIC void world_ents_allocate( world_instance *world ) { { 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_trigger, + k_classtype_particle_box, (void*)&world->triggers, sizeof(struct trigger_zone) }, + +#if 0 { k_classtype_logic_relay, (void*)&world->logic_relays, sizeof(struct logic_relay) }, +#endif + { k_classtype_logic_achievement, + k_classtype_none, (void*)&world->logic_achievements, sizeof(struct logic_achievement) }, { 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) + }, + { + k_classtype_soundscape, + k_classtype_none, + (void*)&world->soundscapes, + sizeof(struct soundscape) } }; @@ -204,7 +220,8 @@ VG_STATIC void world_ents_allocate( world_instance *world ) for( int j=0; jclasstype == entity_counts[j].ct ) + if( (pnode->classtype == entity_counts[j].ct) || + (pnode->classtype == entity_counts[j].ct1) ) { pnode->sub_uid = entity_counts[j].count; entity_counts[j].count ++; @@ -220,7 +237,10 @@ VG_STATIC void world_ents_allocate( world_instance *world ) u32 bufsize = counter->item_size*counter->count; *counter->to_allocate = vg_linear_alloc( world_global.generic_heap, bufsize ); + memset( *counter->to_allocate, 0, bufsize ); } + + logic_bricks_world_gen_allocate( world ); } VG_STATIC void world_pct_spawn( world_instance *world, mdl_node *pnode ) @@ -255,48 +275,20 @@ VG_STATIC void world_pct_audio( world_instance *world, mdl_node *pnode ) v3_copy( pnode->co, thing->pos ); - if( aud->flags & AUDIO_FLAG_SPACIAL_3D ) - thing->volume = aud->volume * pnode->s[0]; - else - thing->volume = aud->volume; + thing->volume = aud->volume; + thing->range = pnode->s[0]; thing->flags = aud->flags; thing->temp_embedded_clip.path = mdl_pstr( world->meta, aud->pstr_file ); thing->temp_embedded_clip.flags = aud->flags; audio_clip_load( &thing->temp_embedded_clip, world_global.generic_heap ); - thing->player.name = mdl_pstr( world->meta, pnode->pstr_name ); - thing->player.enqued = 0; pnode->sub_uid = world->audio_things_count; world->audio_things_count ++; } -VG_STATIC void world_pct_trigger( world_instance *world, mdl_node *pnode ) -{ - struct trigger_zone *trigger = &world->triggers[ world->trigger_count ]; - struct classtype_trigger *inf = mdl_get_entdata( world->meta, pnode ); - - if( inf->target ) - { - mdl_node *target_node = mdl_node_from_id( world->meta, inf->target ); - - trigger->target.sub_id = target_node->sub_uid; - trigger->target.classtype = target_node->classtype; - } - else - { - vg_warn( "Trigger with no target...\n" ); - return; - } - - mdl_node_transform( pnode, trigger->transform ); - m4x3_invert_full( trigger->transform, trigger->inv_transform ); - - world->trigger_count ++; -} - - +#if 0 VG_STATIC void world_pct_relay( world_instance *world, mdl_node *pnode ) { struct logic_relay *relay = &world->logic_relays[ world->relay_count ]; @@ -319,6 +311,7 @@ VG_STATIC void world_pct_relay( world_instance *world, mdl_node *pnode ) v3_copy( pnode->co, relay->pos ); world->relay_count ++; } +#endif VG_STATIC void world_pct_achievement( world_instance *world, mdl_node *pnode ) @@ -373,8 +366,9 @@ VG_STATIC void world_entities_process( world_instance *world ) { k_classtype_spawn, world_pct_spawn }, { k_classtype_water, world_pct_water }, { k_classtype_audio, world_pct_audio }, - { k_classtype_trigger, world_pct_trigger }, +#if 0 { k_classtype_logic_relay, world_pct_relay }, +#endif { k_classtype_logic_achievement, world_pct_achievement }, { k_classtype_world_light, world_pct_world_light }, { k_classtype_nonlocal_gate, world_pct_nonlocal_gate } @@ -764,17 +758,18 @@ VG_STATIC void world_post_process( world_instance *world ) for( int i=0; iaudio_things_count; i++ ) { struct world_audio_thing *thingy = &world->audio_things[ i ]; - - audio_player_init( &thingy->player ); - audio_player_set_flags( &thingy->player, thingy->flags ); - audio_player_set_vol( &thingy->player, thingy->volume ); - audio_player_set_pan( &thingy->player, 0.0f ); - - if( thingy->flags & AUDIO_FLAG_SPACIAL_3D ) - audio_player_set_position( &thingy->player, thingy->pos ); if( thingy->flags & AUDIO_FLAG_AUTO_START ) - audio_player_playclip( &thingy->player, &thingy->temp_embedded_clip ); + { + audio_channel *ch = + audio_request_channel( &thingy->temp_embedded_clip, thingy->flags ); + + audio_channel_edit_volume( ch, thingy->volume, 1 ); + audio_channel_set_spacial( ch, thingy->pos, thingy->range ); + + if( !(ch->flags & AUDIO_FLAG_LOOP) ) + ch = audio_relinquish_channel( ch ); + } } audio_unlock(); @@ -1020,6 +1015,10 @@ VG_STATIC void world_clean( world_instance *world ) /* clean dangling pointers */ world->meta = NULL; + /* + * TODO: Theres probably a better way to do this? + */ + world->textures = NULL; world->texture_count = 0; world->materials = NULL; @@ -1045,8 +1044,10 @@ VG_STATIC void world_clean( world_instance *world ) world->lights = NULL; world->light_count = 0; +#if 0 world->logic_relays = NULL; world->relay_count = 0; +#endif world->logic_achievements = NULL; world->achievement_count = 0; @@ -1063,6 +1064,12 @@ VG_STATIC void world_clean( world_instance *world ) world->collectors = NULL; world->collector_count = 0; + world->soundscapes = NULL; + world->soundscape_count = 0; + + world->logic_bricks = NULL; + world->logic_brick_count = 0; + world->nonlocal_gates = NULL; world->nonlocalgate_count = 0;