-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.h
More file actions
335 lines (280 loc) · 9.5 KB
/
Copy pathProject.h
File metadata and controls
335 lines (280 loc) · 9.5 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#pragma once
#include <filesystem>
#include <map>
#include <string>
#include <vector>
#include "Lux/Asset/AssetManager/EditorAssetManager.h"
#include "Lux/Asset/AssetManager/RuntimeAssetManager.h"
#include "Lux/Core/Base.h"
#include "Lux/Core/Ref.h"
#include "Lux/Renderer/RendererTypes.h"
#include <glm/glm.hpp>
namespace Lux
{
enum class PhysicsAPIType : uint8_t
{
Box2D = 0
};
enum class PhysicsCaptureMethod : uint8_t
{
LiveDebug = 0,
CaptureToFile = 1
};
enum class RuntimeExportTarget : uint8_t
{
Debug = 0,
Release = 1,
Dist = 2
};
const char* RuntimeExportTargetToString(RuntimeExportTarget target);
RuntimeExportTarget RuntimeExportTargetFromString(std::string_view value);
struct ProjectAudioSettings
{
double FileStreamingDurationThreshold = 1.0;
};
struct ProjectPhysicsLayer
{
std::string Name;
bool CollidesWithSelf = true;
std::vector<std::string> CollidesWith;
};
struct ProjectPhysicsSettings
{
float FixedTimestep = 1.0f / 60.0f;
glm::vec3 Gravity = { 0.0f, -9.81f, 0.0f };
uint32_t PositionSolverIterations = 8;
uint32_t VelocitySolverIterations = 2;
uint32_t MaxBodies = 1000;
bool CaptureOnPlay = true;
PhysicsCaptureMethod CaptureMethod = PhysicsCaptureMethod::LiveDebug;
std::vector<ProjectPhysicsLayer> Layers;
};
struct ProjectSceneRendererSettings
{
uint32_t QualityPreset = 1; // Lux::QualityPreset
bool EnableFrustumCulling = true;
bool EnableOcclusionCulling = false;
bool EnableGPUDrivenRendering = true;
bool EnableGTAO = true;
bool GTAOBentNormals = false;
int GTAODenoisePasses = 4;
float AOShadowTolerance = 1.0f;
bool EnableSSR = false;
bool EnableJumpFlood = true;
uint32_t RenderScaleMode = 0; // SceneRendererOptions::RenderResolutionScaleMode
float DynamicResolutionMinScale = 0.5f;
float DynamicResolutionMaxScale = 1.0f;
float DynamicResolutionTargetGPUTime = 16.67f;
float TextureMipBias = 0.0f;
bool EnableDistanceMipBias = false;
float DistanceMipBiasStart = 50.0f;
float DistanceMipBiasEnd = 250.0f;
float DistanceMipBiasMax = 2.0f;
float OcclusionDepthBias = 0.003f;
float OcclusionBoundsScale = 1.15f;
uint32_t GTAOResolutionScale = 2; // SceneRendererOptions::EffectResolutionScale
bool GTAOTemporalAccumulation = false;
float GTAOTemporalBlend = 0.85f;
uint32_t SSRQuality = 1; // SceneRendererOptions::SSRQualityPreset
uint32_t SSRResolutionScale = 2; // SceneRendererOptions::EffectResolutionScale
bool SSRTemporalAccumulation = false;
float SSRTemporalBlend = 0.90f;
bool SoftShadows = true;
bool EnableShadowCulling = true;
float MaxShadowDistance = 200.0f;
float ShadowFade = 25.0f;
float ShadowCascadeSplitLambda = 0.92f;
float ShadowCascadeNearPlaneOffset = 0.0f;
float ShadowCascadeFarPlaneOffset = 50.0f;
float ShadowCascadeTransitionFade = 1.0f;
uint32_t ShadowResolution = 2; // SceneRendererOptions::ShadowResolutionTier
bool BloomEnabled = true;
uint32_t BloomResolutionScale = 2; // SceneRendererOptions::EffectResolutionScale
float BloomThreshold = 1.0f;
float BloomKnee = 0.1f;
float BloomUpsampleScale = 1.0f;
float BloomIntensity = 1.0f;
float BloomDirtIntensity = 1.0f;
bool DOFEnabled = false;
uint32_t DOFResolutionScale = 1; // SceneRendererOptions::EffectResolutionScale
float DOFFocusDistance = 0.0f;
float DOFBlurSize = 1.0f;
bool SSRHalfRes = true;
int SSRMaxSteps = 70;
float SSRBrightness = 0.7f;
float SSRDepthTolerance = 0.8f;
};
struct ProjectRuntimeExportSettings
{
std::string GameName;
uint32_t WindowWidth = 1920;
uint32_t WindowHeight = 1080;
bool Fullscreen = false;
bool VSync = true;
std::filesystem::path IconPath;
AssetHandle IconHandle = 0;
RuntimeExportTarget TargetConfig = RuntimeExportTarget::Release;
};
struct ProjectConfig
{
std::string Name = "Untitled";
std::string StartScene;
AssetHandle StartSceneHandle = 0;
std::filesystem::path AssetDirectory = "Assets";
std::filesystem::path AssetRegistryPath = "Assets/AssetRegistry.lzr";
std::filesystem::path AudioCommandsRegistryPath = "AudioCommandsRegistry.lzr";
std::filesystem::path MeshPath = "Meshes";
std::filesystem::path MeshSourcePath = "Meshes/Source";
std::filesystem::path AnimationPath = "Animation";
std::filesystem::path ScriptModulePath = "Scripts/Binaries/App.dll";
std::string DefaultNamespace = "Untitled";
bool AutomaticallyReloadAssembly = true;
bool EnableAutoSave = false;
int AutoSaveIntervalSeconds = 300;
PhysicsAPIType CurrentPhysicsAPI = PhysicsAPIType::Box2D;
RenderingTechnique RendererTechnique = RenderingTechnique::Forward;
std::string ProjectFileName;
std::filesystem::path ProjectDirectory;
ProjectAudioSettings Audio;
ProjectPhysicsSettings Physics;
ProjectSceneRendererSettings SceneRenderer;
ProjectRuntimeExportSettings RuntimeExport;
};
class Project : public RefCounted
{
public:
const std::filesystem::path& GetProjectDirectory() const { return m_ProjectDirectory; }
const std::filesystem::path& GetProjectFilePath() const { return m_ProjectFilePath; }
std::filesystem::path GetAssetDirectory() const
{
return GetProjectDirectory() / m_Config.AssetDirectory;
}
std::filesystem::path GetAssetRegistryPath() const
{
if (m_Config.AssetRegistryPath.is_absolute())
return m_Config.AssetRegistryPath;
return GetProjectDirectory() / m_Config.AssetRegistryPath;
}
std::filesystem::path GetAssetFileSystemPath(const std::filesystem::path& path) const
{
return GetAssetDirectory() / path;
}
std::filesystem::path GetAssetAbsolutePath(const std::filesystem::path& path) const;
std::filesystem::path GetAudioCommandsRegistryPath() const
{
return GetAssetDirectory() / m_Config.AudioCommandsRegistryPath;
}
std::filesystem::path GetMeshPath() const
{
return GetAssetDirectory() / m_Config.MeshPath;
}
std::filesystem::path GetMeshSourcePath() const
{
return GetAssetDirectory() / m_Config.MeshSourcePath;
}
std::filesystem::path GetAnimationPath() const
{
return GetAssetDirectory() / m_Config.AnimationPath;
}
std::filesystem::path GetScriptModuleFilePath() const
{
return GetAssetDirectory() / m_Config.ScriptModulePath;
}
std::filesystem::path GetScriptModulePath() const
{
return GetScriptModuleFilePath().parent_path();
}
std::filesystem::path GetScriptProjectPath() const
{
return GetAssetDirectory() / "Scripts" / (m_Config.Name + ".csproj");
}
std::filesystem::path GetCacheDirectory() const
{
return GetProjectDirectory() / "Cache";
}
static const std::filesystem::path& GetActiveProjectDirectory()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetProjectDirectory();
}
static std::filesystem::path GetActiveAssetDirectory()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetAssetDirectory();
}
static std::filesystem::path GetActiveAssetRegistryPath()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetAssetRegistryPath();
}
static const std::string& GetProjectName()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetConfig().Name;
}
static std::filesystem::path GetActiveAudioCommandsRegistryPath()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetAudioCommandsRegistryPath();
}
static std::filesystem::path GetActiveMeshPath()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetMeshPath();
}
static std::filesystem::path GetActiveMeshSourcePath()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetMeshSourcePath();
}
static std::filesystem::path GetActiveAnimationPath()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetAnimationPath();
}
static std::filesystem::path GetActiveScriptModuleFilePath()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetScriptModuleFilePath();
}
static std::filesystem::path GetActiveScriptProjectPath()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetScriptProjectPath();
}
static std::filesystem::path GetActiveCacheDirectory()
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetCacheDirectory();
}
static std::filesystem::path GetActiveAssetFileSystemPath(const std::filesystem::path& path)
{
LUX_CORE_ASSERT(s_ActiveProject);
return s_ActiveProject->GetAssetFileSystemPath(path);
}
ProjectConfig& GetConfig() { return m_Config; }
const ProjectConfig& GetConfig() const { return m_Config; }
static Ref<Project> GetActive() { return s_ActiveProject; }
static Ref<AssetManagerBase> GetAssetManager() { return s_AssetManager; }
static Ref<RuntimeAssetManager> GetRuntimeAssetManager() { return s_AssetManager.As<RuntimeAssetManager>(); }
static Ref<EditorAssetManager> GetEditorAssetManager() { return s_AssetManager.As<EditorAssetManager>(); }
static void SetActive(Ref<Project> project);
static void SetActiveRuntime(Ref<Project> project, Ref<AssetPack> assetPack);
void ReloadScriptEngine();
static Ref<Project> New();
static Ref<Project> Load(const std::filesystem::path& path);
static Ref<Project> LoadRuntime(const std::filesystem::path& path, Ref<AssetPack> assetPack);
static bool SaveActive(const std::filesystem::path& path);
private:
void OnSerialized();
void OnDeserialized();
private:
ProjectConfig m_Config;
std::filesystem::path m_ProjectDirectory;
std::filesystem::path m_ProjectFilePath;
inline static Ref<Project> s_ActiveProject;
inline static Ref<AssetManagerBase> s_AssetManager;
friend class ProjectSerializer;
friend class ProjectSettingsWindow;
};
}