Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EcsData.h
Go to the documentation of this file.
1#pragma once
7#include "entt/entt.hpp"
8#include "meshoptimizer.h"
9#include "tiny_gltf.h"
10
11#include <filesystem>
12#include <future>
13#include <glm/glm.hpp>
14#include <optional>
15#include <string>
16#include <vector>
17
18class btCollisionShape;
19class btRigidBody;
20
21namespace EngineCore {
22 class MeshAsset;
23 class MeshComponent;
24 enum PipelineNames : int;
25 class MaterialData;
26 class SceneNode;
27} // namespace EngineCore
28
33namespace Ecs {
34
36 std::filesystem::path path;
37 std::future<tinygltf::Image> future;
38 };
39
43 struct Parent
44 {
45 entt::entity parent;
46 };
47
53 {
54 };
55
62
64 {
65 std::vector<StaticMeshData> meshData;
66 };
67
72
74 std::filesystem::path path;
75 std::future<EngineCore::ExrHeader> future;
76 };
77
79 std::filesystem::path path;
80 std::future<tinygltf::Model> future;
81 };
82
88
89 struct ImageData {
90 tinygltf::Image image;
91 };
92
93 struct Model {
94 tinygltf::Model model;
95 };
96
101 {
102 btRigidBody* rigidBody;
103 btCollisionShape* collisionShape;
104
105 bool isKinematic = false;
106 bool isStatic = false;
107 };
108
113 {
114 };
115
123 {
124 };
125
131 std::weak_ptr<EngineCore::SceneNode> node;
132 };
133
141
149
154 {
155 uint32_t index;
156 };
157 struct Mesh
158 {
159 tinygltf::Mesh mesh;
160 };
161
163 {
164 tinygltf::Node node;
165 };
166
168 {
169 std::vector<Vertex> vertices;
170 std::vector<uint32_t> indices;
171 };
172
176 using Meshlet = meshopt_Meshlet;
177
178 struct MeshletData {
179 std::vector<meshopt_Meshlet> meshlets;
180 std::vector<uint32_t> meshletVertices;
181 std::vector<uint8_t> meshletTriangles;
182 };
183
186 std::vector<PrimitiveData> data;
187 std::vector<Asset::Path> materialPaths;
188 };
189
194 glm::vec3 center = { 0.0f, 0.0f, 0.0f };
195 float radius = 0.0f;
196 };
197
205 uint32_t packed;
206
208 static PackedTriangle pack(uint8_t i0, uint8_t i1, uint8_t i2) {
209 return { static_cast<uint32_t>(i0) |
210 (static_cast<uint32_t>(i1) << 8) |
211 (static_cast<uint32_t>(i2) << 16) };
212 }
213 };
214
215 // Backwards compatibility alias
217
223 std::vector<Vertex> vertices;
224 std::vector<PackedTriangle> triangles;
225 };
226
236 std::vector<EngineCore::ClusterLodData> clusters;
237 std::vector<EngineCore::ClusterGroupData> groups;
238
241
244
246 size_t lodLevelCount = 0;
247 };
248
260
272
274 std::optional<PrimitiveData> data = std::nullopt;
275 std::optional<MeshletData> meshletData = std::nullopt;
276 std::optional<UnpackedMeshletData> unpackedData = std::nullopt;
277 std::optional<LodHierarchyResult> lodHierarchy = std::nullopt;
280 };
281
283 {
284 std::vector<Ecs::MeshPrimitive> primitives;
286 };
287
289 {
290 glm::vec4 color;
291 };
292
294 {
296 };
297
298 struct ModelFuture {
299 std::future<tinygltf::Model> future;
300 };
301
303 glm::mat4 matrix;
304 };
305
307 glm::mat4 matrix;
308 };
309
311 uint32_t depth;
312 };
313
317 struct ActiveCamera { };
318
323 float fov = 60.0f;
324 float nearPlane = 0.01f;
325 float farPlane = 1000.0f;
326 float aspectRatio = 16.0f / 9.0f;
327 };
328
329
330 // ============================================================================
331 // Asset Loading Pipeline Components
332 // ============================================================================
333
338 uint32_t uvCount = 0;
340 };
341
346 struct RawMeshData {
347 std::vector<Vertex> vertices;
348 std::vector<uint32_t> indices;
349 };
350
364
375
376 // Forward declaration for pipeline
377 namespace AssetPipeline {
378 struct RawGeometryData;
379 }
380
389 // Store as void* to avoid forward declaration issues
390 // Will be cast to AssetPipeline::RawGeometryData* when used
391 void* rawGeometryData = nullptr;
392 };
393}
This is the interface which is used to call a tick function on an object. Everything which should be ...
Definition Tick.h:10
The mesh asset stores geometry data and.
Definition MeshAsset.h:15
A component which can be attached as many times to an actor as one wants. It makes it possible to ren...
Represents a node in the scene graph, containing information about its position, rotation,...
Definition SceneGraph.h:24
Data structs for the Entity Component System.
PackedTriangle UnpackedTriangle
Definition EcsData.h:216
AssetLoadingStage
Tracks the current stage of asset loading in the pipeline.
Definition EcsData.h:354
meshopt_Meshlet Meshlet
information about the vertex and index data of a single meshlet
Definition EcsData.h:176
Log category system implementation.
Tag for the active camera in the scene.
Definition EcsData.h:317
std::future< tinygltf::Image > future
Definition EcsData.h:37
std::filesystem::path path
Definition EcsData.h:36
Status information for asset loading pipeline.
Definition EcsData.h:371
AssetLoadingStage stage
Definition EcsData.h:372
std::string lastError
Definition EcsData.h:373
Is a tag for asset loading. When an asset has been rquested for loading but isnt yet created this tag...
Definition EcsData.h:53
A bounding sphere for an entity. Used for frustum culling.
Definition EcsData.h:193
glm::vec3 center
Definition EcsData.h:194
Camera properties for projection matrix calculation.
Definition EcsData.h:322
float fov
Vertical field of view in degrees.
Definition EcsData.h:323
Complete result of meshlet generation for all primitives of a mesh. This is returned from the backgro...
Definition EcsData.h:266
BoundingSphere meshBoundingSphere
Definition EcsData.h:270
std::vector< PrimitiveMeshletResult > primitiveResults
Definition EcsData.h:269
EngineCore::ExrHeader header
Definition EcsData.h:70
std::filesystem::path path
Definition EcsData.h:74
std::future< EngineCore::ExrHeader > future
Definition EcsData.h:75
std::filesystem::path path
Definition EcsData.h:79
std::future< tinygltf::Model > future
Definition EcsData.h:80
tinygltf::Image image
Definition EcsData.h:90
glm::mat4 matrix
Definition EcsData.h:303
Result of LOD hierarchy generation for a mesh primitive. Contains per-cluster and per-group data for ...
Definition EcsData.h:234
std::vector< EngineCore::ClusterLodData > clusters
Per-cluster data (all LOD levels combined)
Definition EcsData.h:236
UnpackedMeshletData unpackedData
Unpacked GPU data for LOD meshlets.
Definition EcsData.h:243
std::vector< EngineCore::ClusterGroupData > groups
Definition EcsData.h:237
MeshletData meshletData
Meshlet data for all clusters (extends base meshlet data)
Definition EcsData.h:240
size_t baseLevelClusterCount
Clusters at LOD 0 (finest level)
Definition EcsData.h:245
size_t lodLevelCount
Number of LOD levels generated.
Definition EcsData.h:246
EngineCore::PipelineNames type
Definition EcsData.h:85
EngineCore::MaterialData * data
Definition EcsData.h:86
Reference to a MeshComponent for ECS-based iteration. Allows efficient querying of all mesh component...
Definition EcsData.h:138
EngineCore::MeshComponent * component
Definition EcsData.h:139
The index of the mesh inside the scene. Used to query the mesh index of a scene.
Definition EcsData.h:154
uint32_t index
Definition EcsData.h:155
std::vector< Ecs::MeshPrimitive > primitives
Definition EcsData.h:284
Ecs::BoundingSphere boundingSphere
Definition EcsData.h:285
std::optional< PrimitiveData > data
Definition EcsData.h:274
std::optional< UnpackedMeshletData > unpackedData
Pre-unpacked GPU-ready data.
Definition EcsData.h:276
std::optional< MeshletData > meshletData
Definition EcsData.h:275
Asset::Path materialPath
Reference to MaterialAsset for pipeline lookup.
Definition EcsData.h:279
std::optional< LodHierarchyResult > lodHierarchy
LOD hierarchy (if generated)
Definition EcsData.h:277
Ecs::BoundingSphere boundingSphere
Definition EcsData.h:278
tinygltf::Mesh mesh
Definition EcsData.h:159
std::vector< uint8_t > meshletTriangles
Definition EcsData.h:181
std::vector< meshopt_Meshlet > meshlets
Definition EcsData.h:179
std::vector< uint32_t > meshletVertices
Definition EcsData.h:180
std::future< tinygltf::Model > future
Definition EcsData.h:299
tinygltf::Node node
Definition EcsData.h:164
tinygltf::Model model
Definition EcsData.h:94
GPU-ready packed triangle data (matches shader layout). Stores 3 x 8-bit local indices packed into a ...
Definition EcsData.h:204
uint32_t packed
3 x 8-bit indices: (i2 << 16) | (i1 << 8) | i0
Definition EcsData.h:205
static PackedTriangle pack(uint8_t i0, uint8_t i1, uint8_t i2)
Pack 3 local indices into a single uint32_t.
Definition EcsData.h:208
Stores parent relationships.
Definition EcsData.h:44
entt::entity parent
Definition EcsData.h:45
Temporary holder for raw geometry data during pipeline execution This is used to pass data between pi...
Definition EcsData.h:388
std::vector< Asset::Path > materialPaths
Resolved material paths per primitive.
Definition EcsData.h:187
std::vector< PrimitiveData > data
Definition EcsData.h:186
std::vector< uint32_t > indices
Definition EcsData.h:170
std::vector< Vertex > vertices
Definition EcsData.h:169
Result of meshlet generation for a single primitive. Used to transfer data from background thread to ...
Definition EcsData.h:253
BoundingSphere boundingSphere
Definition EcsData.h:256
PrimitiveData optimizedData
Optimized vertices and indices.
Definition EcsData.h:255
UnpackedMeshletData unpackedData
GPU-ready unpacked vertex/triangle data.
Definition EcsData.h:257
std::optional< LodHierarchyResult > lodHierarchy
LOD hierarchy (if generated)
Definition EcsData.h:258
Metadata about a primitive being loaded from gltf file.
Definition EcsData.h:337
Raw mesh geometry data extracted from gltf file Contains unprocessed vertices and indices.
Definition EcsData.h:346
std::vector< uint32_t > indices
Definition EcsData.h:348
std::vector< Vertex > vertices
Definition EcsData.h:347
A struct which allows the engine to find out which SceneNode needs to propagate a dirty flag down the...
Definition EcsData.h:130
std::weak_ptr< EngineCore::SceneNode > node
Definition EcsData.h:131
Tag for EnTT which tags entities which should simulate physics.
Definition EcsData.h:101
btCollisionShape * collisionShape
Definition EcsData.h:103
btRigidBody * rigidBody
Definition EcsData.h:102
Asset::Path asset
Definition EcsData.h:58
EngineCore::MeshAsset * assetData
Definition EcsData.h:59
std::vector< StaticMeshData > meshData
Definition EcsData.h:65
Tag for everything which wants to receive tick events.
Definition EcsData.h:146
EngineCore::ITickable * tickable
Definition EcsData.h:147
Tag for transforms that need GPU upload. Separate from TransformDirty because the renderer clears thi...
Definition EcsData.h:123
Tag for dirty transforms (used by scene graph synchronization)
Definition EcsData.h:113
Pre-packed GPU-ready data for a primitive's meshlets. Generated on background thread during meshlet g...
Definition EcsData.h:222
std::vector< PackedTriangle > triangles
Packed triangle indices (4 bytes each)
Definition EcsData.h:224
std::vector< Vertex > vertices
Unpacked vertex data per meshlet.
Definition EcsData.h:223
glm::mat4 matrix
Definition EcsData.h:307
Wrapper for EXR file header information with owned data.
Definition ExrLoader.h:42