-
-
Notifications
You must be signed in to change notification settings - Fork 314
Expand file tree
/
Copy pathcommon.py
More file actions
309 lines (240 loc) · 10.4 KB
/
common.py
File metadata and controls
309 lines (240 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
import glob
def register_scons_options(env, is_extension):
from SCons.Script import BoolVariable, Variables, Help
env_vars = Variables()
env_vars.Add(BoolVariable("voxel_tests",
"Build with tests for the voxel module, which will run on startup of the engine", False))
env_vars.Add(BoolVariable("voxel_smooth_meshing", "Build with smooth voxels meshing support", True))
env_vars.Add(BoolVariable("voxel_modifiers", "Build with experimental modifiers support", True))
env_vars.Add(BoolVariable("voxel_sqlite", "Build with SQLite save stream support", True))
env_vars.Add(BoolVariable("voxel_instancer", "Build with VoxelInstancer support", True))
env_vars.Add(BoolVariable("voxel_gpu", "Build with GPU compute support", True))
env_vars.Add(BoolVariable("voxel_basic_generators", "Build with basic/example generators", True))
env_vars.Add(BoolVariable("voxel_mesh_sdf", "Build with mesh voxelization support", True))
env_vars.Add(BoolVariable("voxel_vox", "Build with support for loading .vox files", True))
if not is_extension:
env_vars.Add(BoolVariable("tracy", "Build with enabled Tracy Profiler integration", False))
env_vars.Add(BoolVariable("voxel_fast_noise_2", "Build FastNoise2 support (x86-only)", True))
env_vars.Add(BoolVariable("voxel_werror", "Explicitely enable warninngs as errors for module code only", False))
env_vars.Update(env)
Help(env_vars.GenerateHelpText(env))
# Gets sources and configurations that are common to compiling as a module and an extension.
# For module-specific configuration, see `SCsub`.
# For extension-specific configuration, see `SConstruct`.
def get_sources(env, is_editor_build):
env.Append(CPPPATH=["."])
env.Append(CPPDEFINES=[
# The MeshOptimizer library in this module is different to the official one.
# Godot 4 includes an official version, which means they would both conflict at linking time.
# To prevent this clash we wrap the entire library within an additional namespace.
"MESHOPTIMIZER_ZYLANN_WRAP_LIBRARY_IN_NAMESPACE",
])
tests_enabled = env["voxel_tests"]
smoosh_meshing_enabled = env["voxel_smooth_meshing"]
modifiers_enabled = env["voxel_modifiers"]
sqlite_enabled = env["voxel_sqlite"]
instancer_enabled = env["voxel_instancer"]
gpu_enabled = env["voxel_gpu"]
basic_generators_enabled = env["voxel_basic_generators"]
voxel_mesh_sdf_enabled = env["voxel_mesh_sdf"]
voxel_vox_enabled = env["voxel_vox"]
if not smoosh_meshing_enabled:
modifiers_enabled = False
if not voxel_mesh_sdf_enabled:
modifiers_enabled = False
sources = [
"constants/*.cpp",
"meshers/blocky/*.cpp",
"meshers/blocky/types/*.cpp",
"meshers/cubes/*.cpp",
"meshers/*.cpp",
"streams/*.cpp",
"streams/region/*.cpp",
"storage/*.cpp",
"storage/metadata/*.cpp",
"generators/generate_block_task.cpp",
"generators/voxel_generator_script.cpp",
"generators/voxel_generator.cpp",
"generators/graph/*.cpp",
"generators/multipass/*.cpp",
"terrain/*.cpp",
"terrain/fixed_lod/*.cpp",
"terrain/variable_lod/*.cpp",
"engine/*.cpp",
"edition/floating_chunks.cpp",
"edition/funcs.cpp",
"edition/raycast.cpp",
"edition/voxel_raycast_result.cpp",
"edition/voxel_tool_buffer.cpp",
"edition/voxel_tool_lod_terrain.cpp",
"edition/voxel_tool_terrain.cpp",
"edition/voxel_tool.cpp",
"shaders/*.cpp",
"register_types.cpp",
# Utility
"util/*.cpp",
"util/containers/*.cpp",
"util/math/*.cpp",
"util/memory/*.cpp",
"util/noise/fast_noise_lite/*.cpp",
"util/noise/gd_noise_range.cpp",
"util/noise/spot_noise_gd.cpp",
"util/string/*.cpp",
"util/thread/thread.cpp",
"util/thread/spatial_lock_2d.cpp",
"util/thread/spatial_lock_3d.cpp",
"util/tasks/*.cpp",
"util/tasks/godot/*.cpp",
"util/godot/classes/array_mesh.cpp",
"util/godot/classes/concave_polygon_shape_3d.cpp",
"util/godot/classes/geometry_2d.cpp",
"util/godot/classes/geometry_instance_3d.cpp",
"util/godot/classes/input_event_key.cpp",
"util/godot/classes/image_texture_3d.cpp",
"util/godot/classes/material.cpp",
"util/godot/classes/mesh.cpp",
"util/godot/classes/multimesh.cpp",
"util/godot/classes/node.cpp",
"util/godot/classes/object.cpp",
"util/godot/classes/project_settings.cpp",
"util/godot/classes/rendering_device.cpp",
"util/godot/classes/rendering_server.cpp",
"util/godot/classes/resource_loader.cpp",
"util/godot/classes/shader.cpp",
"util/godot/classes/shape_3d.cpp",
"util/godot/core/aabb.cpp",
"util/godot/core/string.cpp",
"util/godot/core/variant.cpp",
"util/godot/core/packed_arrays.cpp",
"util/godot/core/packed_byte_array.cpp",
"util/godot/core/rect2i.cpp",
"util/godot/direct_mesh_instance.cpp",
"util/godot/direct_multimesh_instance.cpp",
"util/godot/direct_static_body.cpp",
"util/godot/file_utils.cpp",
"util/godot/shader_material_pool.cpp",
"util/io/*.cpp",
# Thirdparty
"thirdparty/lz4/*.c",
# "thirdparty/sqlite/*.c",
]
if is_editor_build:
sources += [
"editor/*.cpp",
"editor/terrain/*.cpp",
"editor/fast_noise_lite/*.cpp",
"editor/spot_noise/*.cpp",
"editor/graph/*.cpp",
"editor/blocky_library/*.cpp",
"editor/blocky_library/types/*.cpp",
"editor/multipass/*.cpp",
"util/godot/debug_renderer.cpp",
"util/godot/check_ref_ownership.cpp",
"util/godot/classes/editor_plugin.cpp",
"util/godot/classes/editor_file_dialog.cpp",
"util/godot/classes/editor_import_plugin.cpp",
"util/godot/classes/editor_inspector_plugin.cpp",
"util/godot/classes/editor_property.cpp",
"util/godot/classes/editor_settings.cpp",
"util/godot/classes/graph_edit.cpp", # Not editor-only, but only used in editor for now
"util/godot/classes/graph_node.cpp" # Not editor-only, but only used in editor for now
]
if tests_enabled:
env.Append(CPPDEFINES={"VOXEL_TESTS": 1})
sources += [
"util/testing/*.cpp",
"tests/*.cpp",
"tests/util/*.cpp",
"tests/voxel/test_block_serializer.cpp",
"tests/voxel/test_curve_range.cpp",
"tests/voxel/test_edition_funcs.cpp",
"tests/voxel/test_octree.cpp",
"tests/voxel/test_raycast.cpp",
"tests/voxel/test_region_file.cpp",
"tests/voxel/test_storage_funcs.cpp",
"tests/voxel/test_util.cpp",
"tests/voxel/test_voxel_buffer.cpp",
"tests/voxel/test_voxel_data_map.cpp",
"tests/voxel/test_voxel_graph.cpp",
"tests/voxel/test_voxel_instancer.cpp",
"tests/voxel/test_voxel_mesher_cubes.cpp",
]
if smoosh_meshing_enabled:
env.Append(CPPDEFINES={"VOXEL_ENABLE_SMOOTH_MESHING": 1})
sources += [
"meshers/transvoxel/*.cpp",
"engine/detail_rendering/detail_rendering.cpp",
"engine/detail_rendering/render_detail_texture_task.cpp",
"thirdparty/meshoptimizer/*.cpp"
]
if gpu_enabled:
sources += ["engine/detail_rendering/render_detail_texture_gpu_task.cpp"]
if tests_enabled:
sources += [
"tests/voxel/test_detail_rendering_gpu.cpp",
"tests/voxel/test_transvoxel.cpp"
]
if modifiers_enabled:
env.Append(CPPDEFINES={"VOXEL_ENABLE_MODIFIERS": 1})
sources += [
"modifiers/*.cpp",
"modifiers/godot/*.cpp",
]
if sqlite_enabled:
env.Append(CPPDEFINES={"VOXEL_ENABLE_SQLITE": 1})
if env["platform"] == "windows":
# When compiling SQLite with Godot on Windows with MSVC, it produces the following warning:
# `sqlite3.c(42754): warning C4996: 'GetVersionExA': was declared deprecated `
# To fix it, let's indicate to SQLite it should not use this function, even if it is available.
# https://stackoverflow.com/questions/20031597/error-c4996-received-when-compiling-sqlite-c-in-visual-studio-2013
env.Append(CPPDEFINES={"SQLITE_WIN32_GETVERSIONEX": 0})
sources += ["streams/sqlite/*.cpp"]
if tests_enabled:
sources += ["tests/voxel/test_stream_sqlite.cpp"]
if instancer_enabled:
env.Append(CPPDEFINES={"VOXEL_ENABLE_INSTANCER": 1})
sources += [
"terrain/instancing/*.cpp",
]
if is_editor_build:
sources += [
"editor/instancer/*.cpp",
"editor/instance_library/*.cpp",
]
if gpu_enabled:
env.Append(CPPDEFINES={"VOXEL_ENABLE_GPU": 1})
sources += [
"engine/gpu/*.cpp",
"generators/generate_block_gpu_task.cpp",
]
if basic_generators_enabled:
env.Append(CPPDEFINES={"VOXEL_ENABLE_BASIC_GENERATORS": 1})
sources += [
"generators/simple/*.cpp",
]
if voxel_mesh_sdf_enabled:
env.Append(CPPDEFINES={"VOXEL_ENABLE_MESH_SDF": 1})
sources += [
"edition/voxel_mesh_sdf_gd.cpp",
"edition/mesh_sdf.cpp",
]
if is_editor_build:
sources += ["editor/mesh_sdf/*.cpp"]
if tests_enabled:
sources += ["tests/voxel/test_mesh_sdf.cpp"]
if voxel_vox_enabled:
env.Append(CPPDEFINES={"VOXEL_ENABLE_VOX": 1})
sources += ["streams/vox/*.cpp"]
if is_editor_build:
sources += ["editor/vox/*.cpp"]
def process_glob_paths(p_sources):
out = []
for path in p_sources:
if '*' in path:
paths = glob.glob(path)
out += paths
else:
out.append(path)
return out
sources = process_glob_paths(sources)
return sources