cubemaps
[carveJwlIkooP6JGAAIwe30JlM.git] / world.h
1 /*
2 * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4
5 #ifndef WORLD_H
6 #define WORLD_H
7
8 #include "render.h"
9
10 /* types
11 */
12
13 enum world_geo_type{
14 k_world_geo_type_solid = 0,
15 k_world_geo_type_nonsolid = 1,
16 k_world_geo_type_water = 2
17 };
18
19 enum world_purpose{
20 k_world_purpose_hub,
21 k_world_purpose_client
22 }
23 purpose;
24
25 typedef struct world_instance world_instance;
26
27 static void skaterift_world_get_save_path( enum world_purpose which,
28 char buf[128] );
29
30 /* submodule headers */
31 #include "world_entity.h"
32 #include "world_gate.h"
33 #include "world_gen.h"
34 #include "world_info.h"
35 #include "world_load.h"
36 #include "world_physics.h"
37 #include "world_render.h"
38 #include "world_sfd.h"
39 #include "world_volumes.h"
40 #include "world_water.h"
41 #include "world_audio.h"
42 #include "world_routes.h"
43
44 /* console variables */
45
46 static f32 k_day_length = 30.0f; /* minutes */
47 static i32 k_debug_light_indices = 0,
48 k_debug_light_complexity= 0,
49 k_light_preview = 0;
50
51
52 struct world_instance {
53 /* Fixed items
54 * -------------------------------------------------------
55 */
56
57 void *heap;
58 enum world_status{
59 k_world_status_unloaded = 0,
60 k_world_status_loading = 1,
61 k_world_status_loaded = 2,
62 k_world_status_unloading = 3 /* dont spawn sounds and stuff */
63 }
64 status;
65
66 struct{
67 boxf depthbounds;
68 int depth_computed;
69
70 float height;
71 int enabled;
72 v4f plane;
73 }
74 water;
75
76 f64 time;
77
78 /* STD140 */
79 struct ub_world_lighting{
80 v4f g_cube_min,
81 g_cube_inv_range;
82
83 v4f g_water_plane,
84 g_depth_bounds;
85
86 v4f g_daysky_colour;
87 v4f g_nightsky_colour;
88 v4f g_sunset_colour;
89 v4f g_ambient_colour;
90 v4f g_sunset_ambient;
91 v4f g_sun_colour;
92 v4f g_sun_dir;
93 v4f g_board_0;
94 v4f g_board_1;
95
96 float g_water_fog;
97 float g_time;
98 float g_realtime;
99 float g_shadow_length;
100 float g_shadow_spread;
101
102 float g_time_of_day;
103 float g_day_phase;
104 float g_sunset_phase;
105
106 int g_light_preview;
107 int g_shadow_samples;
108
109 int g_debug_indices;
110 int g_debug_complexity;
111 }
112 ub_lighting;
113 GLuint ubo_lighting;
114 int ubo_bind_point;
115
116 GLuint tbo_light_entities,
117 tex_light_entities,
118 tex_light_cubes;
119
120 float probabilities[3];
121
122 v3i light_cubes;
123 struct framebuffer heightmap;
124
125 /*
126 * Dynamically allocated when world_load is called.
127 *
128 * the following arrays index somewhere into this linear
129 * allocator
130 * --------------------------------------------------------------------------
131 */
132
133 /*
134 * Main world .mdl
135 */
136 mdl_context meta;
137
138 GLuint *textures;
139 u32 texture_count;
140
141 struct world_surface{
142 mdl_material info;
143 mdl_submesh sm_geo,
144 sm_no_collide;
145 }
146 * surfaces;
147 u32 surface_count;
148
149 ent_worldinfo info;
150 mdl_array_ptr ent_spawn,
151 ent_gate,
152 ent_light,
153 ent_route_node,
154 ent_path_index,
155 ent_checkpoint,
156 ent_route,
157 ent_water,
158
159 ent_audio_clip,
160 ent_audio,
161 ent_volume,
162 ent_traffic,
163 ent_skateshop,
164 ent_marker,
165 ent_camera,
166 ent_swspreview,
167 ent_ccmd,
168 ent_challenge,
169 ent_unlock,
170 ent_relay,
171 ent_cubemap;
172
173 ent_gate *rendering_gate;
174
175 /* logic
176 * ----------------------------------------------------
177 */
178
179 /* world geometry */
180 scene_context scene_geo,
181 scene_no_collide,
182 scene_lines;
183
184 /* spacial mappings */
185 bh_tree *geo_bh,
186 *entity_bh;
187 u32 *entity_list;
188
189 /* graphics */
190 glmesh mesh_route_lines;
191 glmesh mesh_geo,
192 mesh_no_collide,
193 mesh_water;
194
195 rb_object rb_geo;
196
197 ent_challenge *challenge_target;
198 f32 challenge_timer;
199 };
200
201 struct world_static {
202 /*
203 * Allocated as system memory
204 * --------------------------------------------------------------------------
205 */
206 void *heap;
207
208 u32 current_run_version;
209 double time, rewind_from, rewind_to, last_use;
210
211 u32 active_trigger_volumes[8];
212 u32 active_trigger_volume_count;
213
214 world_instance instances[4];
215 i32 active_instance;
216
217 addon_reg *addon_hub,
218 *addon_client;
219
220 enum world_loader_state{
221 k_world_loader_none,
222 k_world_loader_preload,
223 k_world_loader_load
224 }
225 load_state;
226 }
227 static world_static;
228
229 static void world_init(void);
230 static world_instance *world_current_instance(void);
231
232 #endif /* WORLD_H */