- vg_loader_highwater( world_render_init, world_render_free, NULL );
- vg_loader_highwater( world_sfd_init, world_sfd_free, NULL );
- vg_loader_highwater( world_water_init, world_water_free, NULL );
- vg_loader_highwater( world_gates_init, world_gates_free, NULL );
- vg_loader_highwater( world_routes_init, world_routes_free, NULL );
+ vg_loader_step( world_render_init, NULL );
+ vg_loader_step( world_sfd_init, NULL );
+ vg_loader_step( world_water_init, NULL );
+ vg_loader_step( world_gates_init, NULL );
+ vg_loader_step( world_routes_init, NULL );
+
+ /* Allocate dynamic world memory arena */
+ u32 max_size = 76*1024*1024;
+ world_global.generic_heap = vg_create_linear_allocator( vg_mem.rtmemory,
+ max_size,
+ VG_MEMORY_SYSTEM );
+}
+
+typedef struct ent_call ent_call;
+struct ent_call{
+ ent_index ent;
+ u32 function;
+ void *data;
+};
+
+VG_STATIC void entity_call( world_instance *world, ent_call *call );
+
+VG_STATIC void ent_volume_call( world_instance *world, ent_call *call )
+{
+ ent_volume *volume = mdl_arritm( &world->ent_volume, call->ent.index );
+ if( !volume->target.type ) return;
+
+ if( call->function == k_ent_function_trigger ){
+ call->ent = volume->target;
+
+ if( volume->type == k_volume_subtype_particle ){
+ v3f co;
+ co[0] = vg_randf()*2.0f-1.0f;
+ co[1] = vg_randf()*2.0f-1.0f;
+ co[2] = vg_randf()*2.0f-1.0f;
+ m4x3_mulv( volume->to_world, co, co );
+
+ call->function = k_ent_function_particle_spawn;
+ call->data = co;
+
+ entity_call( world, call );
+ }
+ else if( volume->type == k_volume_subtype_trigger ){
+ /* TODO */
+ }
+ }
+}
+
+VG_STATIC void ent_audio_call( world_instance *world, ent_call *call )
+{
+ ent_audio *audio = mdl_arritm( &world->ent_audio, call->ent.index );
+
+ if( call->function == k_ent_function_particle_spawn ){
+ float chance = vg_randf()*100.0f,
+ bar = 0.0f;
+
+ for( u32 i=0; i<audio->clip_count; i++ ){
+ ent_audio_clip *clip = mdl_arritm( &world->ent_audio_clip,
+ audio->clip_start+i );
+
+ bar += clip->probability;
+
+ if( chance < bar ){
+ float *pos = call->data;
+
+ audio_lock();
+ audio_oneshot_3d( &clip->clip, pos,
+ audio->transform.s[0],
+ audio->volume );
+ audio_unlock();
+ break;
+ }
+ }
+ }