fuckin hell
[carveJwlIkooP6JGAAIwe30JlM.git] / world_gen.h
1 /*
2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4
5 #ifndef WORLD_GEN_H
6 #define WORLD_GEN_H
7
8 #include "world.h"
9
10 /* load world TODO: Put back vg back in loading state while this happens */
11 VG_STATIC void world_load(void);
12
13
14 VG_STATIC void world_add_all_if_material( m4x3f transform, scene *pscene,
15 mdl_context *mdl, u32 id )
16 {
17 for( int i=0; i<mdl->info.node_count; i++ )
18 {
19 mdl_node *pnode = mdl_node_from_id( mdl, i );
20
21 for( int j=0; j<pnode->submesh_count; j++ )
22 {
23 mdl_submesh *sm = mdl_node_submesh( mdl, pnode, j );
24 if( sm->material_id == id )
25 {
26 m4x3f transform2;
27 mdl_node_transform( pnode, transform2 );
28 m4x3_mul( transform, transform2, transform2 );
29
30 scene_add_mdl_submesh( pscene, mdl, sm, transform2 );
31 }
32 }
33 }
34 }
35
36 VG_STATIC void world_add_blob( scene *pscene, ray_hit *hit )
37 {
38 m4x3f transform;
39 v4f qsurface, qrandom;
40 v3f axis;
41
42 v3_cross( (v3f){0.0f,1.0f,0.0f}, hit->normal, axis );
43
44 float angle = v3_dot(hit->normal,(v3f){0.0f,1.0f,0.0f});
45 q_axis_angle( qsurface, axis, angle );
46 q_axis_angle( qrandom, (v3f){0.0f,1.0f,0.0f}, vg_randf()*VG_TAUf );
47 q_mul( qsurface, qrandom, qsurface );
48 q_m3x3( qsurface, transform );
49 v3_copy( hit->pos, transform[3] );
50
51 scene_vert verts[] =
52 {
53 { .co = { -1.00f, 0.0f, 0.0f } },
54 { .co = { 1.00f, 0.0f, 0.0f } },
55 { .co = { -1.00f, 1.2f, 0.0f } },
56 { .co = { 1.00f, 1.2f, 0.0f } },
57 { .co = { -0.25f, 2.0f, 0.0f } },
58 { .co = { 0.25f, 2.0f, 0.0f } }
59 };
60
61 const u32 indices[] = { 0,1,3, 0,3,2, 2,3,5, 2,5,4 };
62
63 if( pscene->vertex_count + vg_list_size(verts) > pscene->max_vertices )
64 vg_fatal_exit_loop( "Scene vertex buffer overflow" );
65
66 if( pscene->indice_count + vg_list_size(indices) > pscene->max_indices )
67 vg_fatal_exit_loop( "Scene index buffer overflow" );
68
69 scene_vert *dst_verts = &pscene->arrvertices[ pscene->vertex_count ];
70 u32 *dst_indices = &pscene->arrindices [ pscene->indice_count ];
71
72 scene_vert *ref = &world.scene_geo->arrvertices[ hit->tri[0] ];
73
74 for( u32 i=0; i<vg_list_size(verts); i++ )
75 {
76 scene_vert *pvert = &dst_verts[ i ],
77 *src = &verts[ i ];
78
79 m4x3_mulv( transform, src->co, pvert->co );
80 scene_vert_pack_norm( pvert, transform[1] );
81
82 v2_copy( ref->uv, pvert->uv );
83 }
84
85 for( u32 i=0; i<vg_list_size(indices); i++ )
86 dst_indices[i] = indices[i] + pscene->vertex_count;
87
88 pscene->vertex_count += vg_list_size(verts);
89 pscene->indice_count += vg_list_size(indices);
90 }
91
92 /* Sprinkle foliage models over the map on terrain material */
93 VG_STATIC void world_apply_procedural_foliage( struct world_material *mat )
94 {
95 if( vg.quality_profile == k_quality_profile_low )
96 return;
97
98 vg_info( "Applying foliage (%u)\n", mat->info.pstr_name );
99
100 vg_linear_clear( vg_mem.scratch );
101
102 mdl_context *mfoliage =
103 mdl_load_full( vg_mem.scratch, "models/rs_foliage.mdl");
104
105 v3f volume;
106 v3_sub( world.scene_geo->bbx[1], world.scene_geo->bbx[0], volume );
107 volume[1] = 1.0f;
108
109 mdl_node *mblob = mdl_node_from_name( mfoliage, "blob" );
110 mdl_submesh *sm_blob = mdl_node_submesh( mfoliage, mblob, 0 );
111
112 int count = 0;
113
114 float area = volume[0]*volume[2];
115 u32 particles = 0.08f * area;
116
117 vg_info( "Map area: %f. Max particles: %u\n", area, particles );
118
119 for( int i=0;i<particles;i++ )
120 {
121 v3f pos;
122 v3_mul( volume, (v3f){ vg_randf(), 1000.0f, vg_randf() }, pos );
123 pos[1] = 1000.0f;
124 v3_add( pos, world.scene_geo->bbx[0], pos );
125
126 ray_hit hit;
127 hit.dist = INFINITY;
128
129 if( ray_world( pos, (v3f){0.0f,-1.0f,0.0f}, &hit ))
130 {
131 struct world_material *m1 = ray_hit_material( &hit );
132 if((hit.normal[1] > 0.8f) && (m1 == mat) && (hit.pos[1] > 0.0f+10.0f))
133 {
134 world_add_blob( world.scene_no_collide, &hit );
135 count ++;
136 }
137 }
138 }
139
140 vg_info( "%d foliage models added\n", count );
141 }
142
143 VG_STATIC void world_ents_allocate(void)
144 {
145 vg_info( "Allocating entities\n" );
146
147 /* count entites to allocate buffers for them.
148 * maybe in the future we just store these numbers in the model file...
149 *
150 * TODO: use this in world_routes too */
151
152 struct countable
153 {
154 enum classtype ct;
155 void **to_allocate;
156 u32 item_size;
157 int count;
158 }
159 entity_counts[] =
160 {
161 {
162 k_classtype_spawn,
163 (void*)&world.spawns,
164 sizeof(struct respawn_point)
165 },
166 {
167 k_classtype_audio,
168 (void*)&world.audio_things,
169 sizeof(struct world_audio_thing)
170 },
171 {
172 k_classtype_trigger,
173 (void*)&world.triggers,
174 sizeof(struct trigger_zone)
175 },
176 {
177 k_classtype_logic_relay,
178 (void*)&world.logic_relays,
179 sizeof(struct logic_relay)
180 },
181 {
182 k_classtype_logic_achievement,
183 (void*)&world.logic_achievements,
184 sizeof(struct logic_achievement)
185 },
186 {
187 k_classtype_point_light,
188 (void*)&world.lights,
189 sizeof(struct world_light)
190 }
191 };
192
193 for( int i=0; i<vg_list_size(entity_counts); i++ )
194 entity_counts[i].count = 0;
195
196 for( int i=0; i<world.meta->info.node_count; i++ )
197 {
198 mdl_node *pnode = mdl_node_from_id( world.meta, i );
199
200 for( int j=0; j<vg_list_size(entity_counts); j ++ )
201 {
202 if( pnode->classtype == entity_counts[j].ct )
203 {
204 pnode->sub_uid = entity_counts[j].count;
205 entity_counts[j].count ++;
206 break;
207 }
208 }
209 }
210
211 for( int i=0; i<vg_list_size(entity_counts); i++ )
212 {
213 struct countable *counter = &entity_counts[i];
214
215 u32 bufsize = counter->item_size*counter->count;
216 *counter->to_allocate = vg_linear_alloc( world.dynamic_vgl, bufsize );
217 }
218 }
219
220 VG_STATIC void world_pct_spawn( mdl_node *pnode )
221 {
222 struct respawn_point *rp = &world.spawns[ world.spawn_count ++ ];
223
224 v3_copy( pnode->co, rp->co );
225 v4_copy( pnode->q, rp->q );
226 rp->name = mdl_pstr( world.meta, pnode->pstr_name );
227 }
228
229 VG_STATIC void world_pct_water( mdl_node *pnode )
230 {
231 if( world.water.enabled )
232 {
233 vg_warn( "Multiple water surfaces in level! ('%s')\n",
234 mdl_pstr( world.meta, pnode->pstr_name ));
235 return;
236 }
237
238 world.water.enabled = 1;
239 water_set_surface( pnode->co[1] );
240 }
241
242 VG_STATIC void world_pct_audio( mdl_node *pnode )
243 {
244 struct world_audio_thing *thing = &world.audio_things[
245 world.audio_things_count ];
246
247 memset( thing, 0, sizeof(struct world_audio_thing) );
248 struct classtype_audio *aud = mdl_get_entdata( world.meta, pnode );
249
250 v3_copy( pnode->co, thing->pos );
251
252 if( aud->flags & AUDIO_FLAG_SPACIAL_3D )
253 thing->volume = aud->volume * pnode->s[0];
254 else
255 thing->volume = aud->volume;
256
257 thing->flags = aud->flags;
258 thing->temp_embedded_clip.path = mdl_pstr( world.meta, aud->pstr_file );
259 thing->temp_embedded_clip.source_mode = k_audio_source_mono;
260
261 audio_clip_load( &thing->temp_embedded_clip, world.audio_vgl );
262 thing->player.name = mdl_pstr( world.meta, pnode->pstr_name );
263 thing->player.enqued = 0;
264
265 pnode->sub_uid = world.audio_things_count;
266 world.audio_things_count ++;
267 }
268
269
270 VG_STATIC void world_pct_trigger( mdl_node *pnode )
271 {
272 struct trigger_zone *trigger = &world.triggers[ world.trigger_count ];
273 struct classtype_trigger *inf = mdl_get_entdata( world.meta, pnode );
274
275 if( inf->target )
276 {
277 mdl_node *target_node = mdl_node_from_id( world.meta, inf->target );
278
279 trigger->target.sub_id = target_node->sub_uid;
280 trigger->target.classtype = target_node->classtype;
281 }
282 else
283 {
284 vg_warn( "Trigger with no target...\n" );
285 return;
286 }
287
288 mdl_node_transform( pnode, trigger->transform );
289 m4x3_invert_full( trigger->transform, trigger->inv_transform );
290
291 world.trigger_count ++;
292 }
293
294
295 VG_STATIC void world_pct_relay( mdl_node *pnode )
296 {
297 struct logic_relay *relay = &world.logic_relays[ world.relay_count ];
298 struct classtype_logic_relay *inf = mdl_get_entdata( world.meta, pnode );
299
300 relay->target_count = 0;
301
302 for( int i=0; i<vg_list_size(relay->targets); i++ )
303 {
304 if( inf->targets[i] )
305 {
306 struct relay_target *target = &relay->targets[relay->target_count ++];
307 mdl_node *other = mdl_node_from_id( world.meta, inf->targets[i] );
308
309 target->classtype = other->classtype;
310 target->sub_id = other->sub_uid;
311 }
312 }
313
314 v3_copy( pnode->co, relay->pos );
315 world.relay_count ++;
316 }
317
318
319 VG_STATIC void world_pct_achievement( mdl_node *pnode )
320 {
321 struct logic_achievement *ach =
322 &world.logic_achievements[ world.achievement_count ];
323 struct classtype_logic_achievement *inf =
324 mdl_get_entdata( world.meta, pnode );
325
326 v3_copy( pnode->co, ach->pos );
327 ach->achievement_id = mdl_pstr( world.meta, inf->pstr_name );
328 ach->achieved = 0;
329
330 world.achievement_count ++;
331 }
332
333 VG_STATIC void world_pct_point_light( mdl_node *pnode )
334 {
335 struct world_light *light = &world.lights[ world.light_count ];
336 v3_copy( pnode->co, light->co );
337
338 struct classtype_point_light *inf = mdl_get_entdata( world.meta, pnode );
339 v4_copy( inf->colour, light->colour );
340
341 world.light_count ++;
342 }
343
344 VG_STATIC void world_entities_process(void)
345 {
346 struct entity_instruction
347 {
348 enum classtype ct;
349 void (*process)( mdl_node *pnode );
350 }
351 entity_instructions[] =
352 {
353 { k_classtype_spawn, world_pct_spawn },
354 { k_classtype_water, world_pct_water },
355 { k_classtype_audio, world_pct_audio },
356 { k_classtype_trigger, world_pct_trigger },
357 { k_classtype_logic_relay, world_pct_relay },
358 { k_classtype_logic_achievement, world_pct_achievement },
359 { k_classtype_point_light, world_pct_point_light }
360 };
361
362 for( int i=0; i<world.meta->info.node_count; i++ )
363 {
364 mdl_node *pnode = mdl_node_from_id( world.meta, i );
365
366 for( int j=0; j<vg_list_size(entity_instructions); j++ )
367 {
368 struct entity_instruction *instr = &entity_instructions[j];
369
370 if( pnode->classtype == instr->ct )
371 {
372 instr->process( pnode );
373 break;
374 }
375 }
376 }
377 }
378
379 VG_STATIC void world_scene_compute_light_clusters( scene *sc )
380 {
381 for( int i=0; i<sc->vertex_count; i++ )
382 {
383 scene_vert *vert = &sc->arrvertices[i];
384 vert->lights[0] = 255;
385 vert->lights[1] = 255;
386 vert->lights[2] = 255;
387 vert->lights[3] = 255;
388
389 float distances[4] = { INFINITY, INFINITY, INFINITY, INFINITY };
390
391 for( int j=0; j<world.light_count; j ++ )
392 {
393 float dist = v3_dist2( world.lights[j].co, vert->co );
394
395 int best_pos = 4;
396 for( int k=best_pos-1; k>=0; k -- )
397 if( dist < distances[k] )
398 best_pos = k;
399
400 if( best_pos < 4 )
401 {
402 for( int k=3; k>best_pos; k -- )
403 {
404 distances[k] = distances[k-1];
405 vert->lights[k] = vert->lights[k-1];
406 }
407
408 distances[best_pos] = dist;
409 vert->lights[best_pos] = j;
410 }
411 }
412 }
413 }
414
415 VG_STATIC void world_generate(void)
416 {
417 /*
418 * Compile meshes into the world scenes
419 */
420 world.scene_geo = scene_init( world.dynamic_vgl, 320000, 1200000 );
421
422 m4x3f midentity;
423 m4x3_identity( midentity );
424
425 /*
426 * Generate scene: collidable geometry
427 * ----------------------------------------------------------------
428 */
429
430 vg_info( "Generating collidable geometry\n" );
431
432
433 for( int i=0; i<world.material_count; i++ )
434 {
435 struct world_material *mat = &world.materials[ i ];
436
437 if( mat->info.flags & k_material_flag_collision )
438 world_add_all_if_material( midentity, world.scene_geo, world.meta, i );
439
440 scene_copy_slice( world.scene_geo, &mat->sm_geo );
441 }
442 world_scene_compute_light_clusters( world.scene_geo );
443
444 /* compress that bad boy */
445 world.scene_geo = scene_fix( world.dynamic_vgl, world.scene_geo );
446
447 vg_acquire_thread_sync();
448 {
449 scene_upload( world.scene_geo, &world.mesh_geo );
450 }
451 vg_release_thread_sync();
452
453 /* setup spacial mapping and rigidbody */
454 world.geo_bh = scene_bh_create( world.dynamic_vgl, world.scene_geo );
455
456 v3_zero( world.rb_geo.co );
457 q_identity( world.rb_geo.q );
458
459 world.rb_geo.type = k_rb_shape_scene;
460 world.rb_geo.inf.scene.bh_scene = world.geo_bh;
461 world.rb_geo.is_world = 1;
462 rb_init( &world.rb_geo );
463
464 /*
465 * Generate scene: non-collidable geometry
466 * ----------------------------------------------------------------
467 */
468 vg_info( "Generating non-collidable geometry\n" );
469
470 world.scene_no_collide = scene_init( world.dynamic_vgl, 200000, 500000 );
471
472 for( int i=0; i<world.material_count; i++ )
473 {
474 struct world_material *mat = &world.materials[ i ];
475
476 if( !(mat->info.flags & k_material_flag_collision) )
477 {
478 world_add_all_if_material( midentity, world.scene_no_collide,
479 world.meta, i );
480 }
481
482 if( mat->info.flags & k_material_flag_grow_grass )
483 world_apply_procedural_foliage( mat );
484
485 scene_copy_slice( world.scene_no_collide, &mat->sm_no_collide );
486 }
487 world_scene_compute_light_clusters( world.scene_no_collide );
488
489 /* upload and free that */
490 vg_acquire_thread_sync();
491 {
492 scene_upload( world.scene_no_collide, &world.mesh_no_collide );
493 }
494 vg_release_thread_sync();
495
496 vg_linear_del( world.dynamic_vgl, world.scene_no_collide );
497 world.scene_no_collide = NULL;
498 }
499
500 VG_STATIC int reset_player( int argc, char const *argv[] );
501 VG_STATIC void world_post_process(void)
502 {
503 /* initialize audio if need be */
504 audio_lock();
505 for( int i=0; i<world.audio_things_count; i++ )
506 {
507 struct world_audio_thing *thingy = &world.audio_things[ i ];
508
509 audio_player_init( &thingy->player );
510 audio_player_set_flags( &thingy->player, thingy->flags );
511 audio_player_set_vol( &thingy->player, thingy->volume );
512 audio_player_set_pan( &thingy->player, 0.0f );
513
514 if( thingy->flags & AUDIO_FLAG_SPACIAL_3D )
515 audio_player_set_position( &thingy->player, thingy->pos );
516
517 if( thingy->flags & AUDIO_FLAG_AUTO_START )
518 audio_player_playclip( &thingy->player, &thingy->temp_embedded_clip );
519 }
520 audio_unlock();
521
522 vg_acquire_thread_sync();
523 {
524 /*
525 * Rendering the depth map
526 */
527 camera ortho;
528
529 v3f extent;
530 v3_sub( world.scene_geo->bbx[1], world.scene_geo->bbx[0], extent );
531
532 float fl = world.scene_geo->bbx[0][0],
533 fr = world.scene_geo->bbx[1][0],
534 fb = world.scene_geo->bbx[0][2],
535 ft = world.scene_geo->bbx[1][2],
536 rl = 1.0f / (fr-fl),
537 tb = 1.0f / (ft-fb);
538
539 m4x4_zero( ortho.mtx.p );
540 ortho.mtx.p[0][0] = 2.0f * rl;
541 ortho.mtx.p[2][1] = 2.0f * tb;
542 ortho.mtx.p[3][0] = (fr + fl) * -rl;
543 ortho.mtx.p[3][1] = (ft + fb) * -tb;
544 ortho.mtx.p[3][3] = 1.0f;
545 m4x3_identity( ortho.transform );
546 camera_update_view( &ortho );
547 camera_finalize( &ortho );
548
549 glDisable(GL_DEPTH_TEST);
550 glDisable(GL_BLEND);
551 glDisable(GL_CULL_FACE);
552 render_fb_bind( gpipeline.fb_heightmap );
553 shader_blitcolour_use();
554 shader_blitcolour_uColour( (v4f){-9999.0f,-9999.0f,-9999.0f,-9999.0f} );
555 render_fsquad();
556
557 /* todo: hmm?? */
558 glEnable(GL_BLEND);
559 glBlendFunc(GL_ONE, GL_ONE);
560 glBlendEquation(GL_MAX);
561
562 render_world_depth( &ortho );
563 glDisable(GL_BLEND);
564 glEnable(GL_DEPTH_TEST);
565 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
566
567 /*
568 * TODO: World settings entity
569 */
570 struct ub_world_lighting *winfo = &gpipeline.ub_world_lighting;
571
572 if( world.water.enabled )
573 v4_copy( world.water.plane, winfo->g_water_plane );
574
575 v4f info_vec;
576 v3f *bounds = world.scene_geo->bbx;
577
578 info_vec[0] = bounds[0][0];
579 info_vec[1] = bounds[0][2];
580 info_vec[2] = 1.0f/ (bounds[1][0]-bounds[0][0]);
581 info_vec[3] = 1.0f/ (bounds[1][2]-bounds[0][2]);
582 v4_copy( info_vec, winfo->g_depth_bounds );
583
584 winfo->g_water_fog = 0.04f;
585
586 for( int i=0; i<world.light_count; i++ )
587 {
588 struct world_light *light = &world.lights[i];
589
590 v3_muls( light->colour, light->colour[3] * 2.0f,
591 gpipeline.ub_world_lighting.g_point_light_colours[i] );
592 v3_copy( light->co,
593 gpipeline.ub_world_lighting.g_point_light_positions[i] );
594 }
595
596 render_update_lighting_ub();
597 }
598
599 vg_release_thread_sync();
600
601 #if 0
602 /*
603 * Setup scene collider
604 */
605 reset_player( 1, (const char *[]){"start"} );
606 #endif
607 }
608
609 VG_STATIC void world_process_resources(void)
610 {
611 vg_info( "Loading textures\n" );
612 world.texture_count = world.meta->info.texture_count;
613 world.textures =
614 vg_linear_alloc( world.dynamic_vgl, sizeof(GLuint)*world.texture_count );
615
616 vg_acquire_thread_sync();
617 {
618 /* error texture */
619 world.textures[0] = vg_tex2d_new();
620 vg_tex2d_set_error();
621 vg_tex2d_nearest();
622 vg_tex2d_repeat();
623
624 for( int i=1; i<world.texture_count; i++ )
625 {
626 mdl_texture *tex = &world.meta->texture_buffer[i];
627
628 if( !tex->pack_offset )
629 {
630 vg_release_thread_sync();
631 vg_fatal_exit_loop( "World models must have packed textures!" );
632 }
633
634 vg_linear_clear( vg_mem.scratch );
635 world.textures[i] = vg_tex2d_new();
636 vg_tex2d_set_error();
637 vg_tex2d_qoi( world.meta->pack + tex->pack_offset, tex->pack_length,
638 mdl_pstr( world.meta, tex->pstr_name ));
639 vg_tex2d_nearest();
640 vg_tex2d_repeat();
641 }
642 }
643 vg_release_thread_sync();
644
645 vg_info( "Loading materials\n" );
646
647 u32 size = sizeof(struct world_material) * world.meta->info.material_count;
648 world.materials = vg_linear_alloc( world.dynamic_vgl, size );
649
650 world.material_count = world.meta->info.material_count;
651 memset( world.materials, 0, size );
652
653 for( int i=1; i<world.material_count; i++ )
654 world.materials[i].info = world.meta->material_buffer[i];
655
656 /* error material */
657 struct world_material *errmat = &world.materials[0];
658 v4_copy( (v4f){ 1.0f,0.0f,0.0f,1.0f }, errmat->info.colour );
659 v4_copy( (v4f){ 1.0f,0.0f,0.0f,1.0f }, errmat->info.colour1 );
660 errmat->info.flags = 0x00;
661 errmat->info.pstr_name = 0; /* useless? */
662 errmat->info.shader = -1;
663 errmat->info.tex_decal = 0;
664 errmat->info.tex_diffuse = 0;
665 errmat->info.tex_normal = 0;
666 }
667
668 VG_STATIC void world_unload(void)
669 {
670 vg_acquire_thread_sync();
671
672 /* free meshes */
673 mesh_free( &world.mesh_route_lines );
674 mesh_free( &world.mesh_geo );
675 mesh_free( &world.mesh_no_collide );
676
677 world.time = 0.0;
678 world.rewind_from = 0.0;
679 world.rewind_to = 0.0;
680 world.last_use = 0.0;
681 world.active_gate = 0;
682 world.current_run_version = 2;
683 world.active_route_board = 0;
684 v3_zero( world.render_gate_pos );
685
686 for( int i=0; i<vg_list_size(world.ui_bars); i++ )
687 {
688 struct route_ui_bar *uib = &world.ui_bars[i];
689 uib->segment_start = 0;
690 uib->segment_count = 0;
691 uib->fade_start = 0;
692 uib->fade_count = 0;
693 uib->fade_timer_start = 0.0;
694 uib->xpos = 0.0f;
695 }
696
697 /* delete textures and meshes */
698 glDeleteTextures( world.texture_count, world.textures );
699
700 /* delete the entire block of memory */
701 vg_linear_clear( world.dynamic_vgl );
702 vg_linear_clear( world.audio_vgl );
703
704 /* clean dangling pointers */
705 world.meta = NULL;
706
707 world.textures = NULL;
708 world.texture_count = 0;
709 world.materials = NULL;
710 world.material_count = 0;
711
712 world.scene_geo = NULL;
713 world.scene_no_collide = NULL;
714 world.scene_lines = NULL;
715
716 world.geo_bh = NULL;
717 world.trigger_bh = NULL;
718 world.audio_bh = NULL;
719
720 world.spawns = NULL;
721 world.spawn_count = 0;
722
723 world.audio_things = NULL;
724 world.audio_things_count = 0;
725
726 world.triggers = NULL;
727 world.trigger_count = 0;
728
729 world.lights = NULL;
730 world.light_count = 0;
731
732 world.logic_relays = NULL;
733 world.relay_count = 0;
734
735 world.logic_achievements = NULL;
736 world.achievement_count = 0;
737
738 world.nodes = NULL;
739 world.node_count = 0;
740
741 world.routes = NULL;
742 world.route_count = 0;
743
744 world.gates = NULL;
745 world.gate_count = 0;
746
747 world.collectors = NULL;
748 world.collector_count = 0;
749
750 world.water.enabled = 0;
751
752 vg_release_thread_sync();
753 }
754
755 VG_STATIC void world_load(void)
756 {
757 world_unload();
758
759 world.meta = mdl_load_full( world.dynamic_vgl, world.world_name );
760 vg_info( "Loading world: %s\n", world.world_name );
761
762 /* process resources from pack */
763 world_process_resources();
764
765 /* dynamic allocations */
766 world_ents_allocate();
767 world_routes_allocate();
768
769 /* meta processing */
770 world_routes_process();
771 world_entities_process();
772
773 /* main bulk */
774 world_generate();
775 world_routes_generate();
776 world_post_process();
777 }
778
779 #endif /* WORLD_GEN_H */