+ k_logic_type_relay = 1,
+ k_logic_type_chance = 2,
+ k_logic_type_achievement = 3
+};
+
+enum geo_type
+{
+ k_geo_type_solid = 0,
+ k_geo_type_nonsolid = 1,
+ k_geo_type_water = 2
+};
+
+static const float k_light_cube_size = 8.0f;
+
+struct world_instance {
+ /* Fixed items
+ * -------------------------------------------------------
+ */
+
+ void *heap;
+ char world_name[ 64 ];
+ enum world_status{
+ k_world_status_unloaded = 0,
+ k_world_status_loading = 1,
+ k_world_status_loaded = 2
+ }
+ status;
+
+ struct{
+ boxf depthbounds;
+ int depth_computed;
+
+ float height;
+ int enabled;
+ v4f plane;
+ }
+ water;
+
+ /* STD140 */
+ struct ub_world_lighting{
+ v4f g_cube_min,
+ g_cube_inv_range;
+
+ v4f g_water_plane,
+ g_depth_bounds;
+
+ v4f g_daysky_colour;
+ v4f g_nightsky_colour;
+ v4f g_sunset_colour;
+ v4f g_ambient_colour;
+ v4f g_sunset_ambient;
+ v4f g_sun_colour;
+ v4f g_sun_dir;
+ v4f g_board_0;
+ v4f g_board_1;
+
+ float g_water_fog;
+ float g_time;
+ float g_realtime;
+ float g_shadow_length;
+ float g_shadow_spread;
+
+ float g_time_of_day;
+ float g_day_phase;
+ float g_sunset_phase;
+
+ int g_light_preview;
+ int g_shadow_samples;
+
+ int g_debug_indices;
+ int g_debug_complexity;
+ }
+ ub_lighting;
+ GLuint ubo_lighting;
+ int ubo_bind_point;
+
+ GLuint tbo_light_entities,
+ tex_light_entities,
+ tex_light_cubes;
+
+ float probabilities[3];
+
+ v3i light_cubes;
+
+ struct framebuffer heightmap;
+
+ /*
+ * Dynamically allocated when world_load is called.
+ *
+ * the following arrays index somewhere into this linear
+ * allocator
+ *
+ * (world_gen.h)
+ * --------------------------------------------------------------------------
+ */
+
+ /*
+ * Main world .mdl
+ */
+ mdl_context meta;
+
+ GLuint *textures;
+ u32 texture_count;
+
+ struct world_surface{
+ mdl_material info;
+ mdl_submesh sm_geo,
+ sm_no_collide;
+ }
+ * surfaces;
+ u32 surface_count;
+
+ mdl_array_ptr ent_spawn,
+ ent_gate,
+ ent_light,
+ ent_route_node,
+ ent_path_index,
+ ent_checkpoint,
+ ent_route,
+ ent_water,
+
+ ent_audio_clip,
+ ent_audio,
+ ent_volume,
+ ent_traffic,
+ ent_skateshop,
+ ent_marker,
+ ent_camera,
+ ent_swspreview;
+
+ ent_gate *rendering_gate;
+
+ /* logic
+ * ----------------------------------------------------
+ */
+
+ /* world geometry */
+ scene_context scene_geo,
+ scene_no_collide,
+ scene_lines;
+
+ /* spacial mappings */
+ bh_tree *audio_bh,
+ *volume_bh,
+ *geo_bh;
+
+ /* graphics */
+ glmesh mesh_route_lines;
+ glmesh mesh_geo,
+ mesh_no_collide,
+ mesh_water;
+
+ rb_object rb_geo;
+};
+
+struct world_global{
+ /*
+ * Allocated as system memory
+ * --------------------------------------------------------------------------
+ */
+ void *heap;
+
+ /* rendering */
+ glmesh skydome;
+ glmesh mesh_gate;
+ mdl_submesh sm_gate_surface,
+ sm_gate_marker[4];
+
+ double sky_time, sky_rate, sky_target_rate;
+
+ u32 current_run_version;
+ double time, rewind_from, rewind_to, last_use;
+
+ /* water rendering */
+ struct{
+ struct framebuffer fbreflect, fbdepth;
+ }
+ water;
+
+ /* split flap display */
+ struct{
+ glmesh mesh_base, mesh_display;
+ mdl_submesh sm_base;
+ u32 active_route_board;
+ scene_context scene;
+
+ u32 w, h;
+ float *buffer;
+ }
+ sfd;
+
+ v3f render_gate_pos;
+ int in_volume;
+
+ int switching_to_new_world;
+
+ world_instance worlds[4];
+ u32 world_count;
+ u32 active_world;
+
+ /* text particles */
+ font3d font;
+
+ struct timer_text{
+ char text[8];
+ m4x3f transform;
+ ent_gate *gate;
+ ent_route *route;
+ }
+ timer_texts[4];
+ u32 timer_text_count;
+
+ struct text_particle{
+ rb_object obj;
+ m4x3f mlocal;
+ ent_glyph *glyph;
+ v4f colour;