Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
MeshPrimitive.h
Go to the documentation of this file.
1#pragma once
4#include "GltfLoader.h"
5#include "Vertex.h"
6
7#include <meshoptimizer.h>
8
9namespace EngineCore
10{
11 struct MeshletBounds;
12 class Texture;
13class Mesh;
14class Renderer;
16class Material;
17struct MaterialShader;
18}
19namespace EngineCore {
21 friend Mesh;
22 public:
23 MeshPrimitive() = default;
26
27 [[nodiscard]] std::vector<Vertex> getVertices() const;
28 [[nodiscard]] const std::vector<Vertex>& getVerticesByRef() const;
29 [[nodiscard]] std::vector<uint32_t> getIndices() const;
30 [[nodiscard]] const std::vector<uint32_t>& getIndicesByRef() const;
31
32 [[nodiscard]] uint32_t getTextureIndex() const;
33
34 [[nodiscard]] std::vector<meshopt_Meshlet> getMeshlets() const;
35 [[nodiscard]] const std::vector<meshopt_Meshlet>& getMeshletByRef() const;
36 [[nodiscard]] std::vector<uint8_t> getMeshletTriangles() const;
37 [[nodiscard]] const std::vector<uint8_t>& getMeshletTrianglesByRef() const;
38 [[nodiscard]] std::vector<uint32_t> getMeshletVertices() const;
39 [[nodiscard]] const std::vector<uint32_t>& getMeshletVerticesByRef() const;
40
41 [[nodiscard]] uint32_t getMeshletTriangleCount() const;
42 [[nodiscard]] uint32_t getMeshletVertexCount() const;
43 [[nodiscard]] uint32_t getMeshletsCount() const;
44 [[nodiscard]] float getBoundingSphereRadius() const;
45 [[nodiscard]] glm::vec3 getBoundingSphereCenter() const;
46 [[nodiscard]] ObjectCullingData getCullingData() const;
47 [[nodiscard]] bool hasCustomTexture() const;
48
49 [[nodiscard]] PipelineNames getMaterialName() const;
50 [[nodiscard]] MaterialShader* getMaterialShader() const;
52
53 void setMaterialId(uint32_t materialId);
54
56 const std::vector<MeshletBounds> &getMeshletBoundsByRef() const;
57
58 private:
59
60 void generateMeshlets();
62
64 MeshletBoundsHelper(glm::vec3 init) : minX(init), maxX(init), minY(init), maxY(init), minZ(init), maxZ(init) {};
65 void enlarge(glm::vec3 point);
66 MeshletBounds getBounds(const std::vector<meshopt_Meshlet> &meshlets, const std::vector<Vertex> &vertices, const std::vector<uint32_t> &meshletVertices) const;
67 glm::vec3 minX, maxX, minY, maxY, minZ, maxZ;
68 };
69
70 public:
71 std::vector<meshopt_Meshlet> meshlets{};
72 std::vector<MeshletBounds> meshletBounds{};
73 private:
74
77 uint32_t materialId = 0;
78 std::variant<
89
90 public:
96
97 private:
98 std::vector<uint32_t> meshletVertices{};
99 std::vector<uint8_t> meshletTriangles{};
100
101 ObjectCullingData objectCullingData{.worldPositionAndRadius = {0.0f, 0.0f, 0.0f, 0.0f}, .objectIndex = 0};
102
104 Renderer* renderer = nullptr;
105
106 uint32_t textureIndex = 0;
108
109 std::vector<Vertex> vertices;
110 std::vector<uint32_t> indices;
111 };
112}
The application context is the core class which stores the basic openxr and vulkan objects.
Material data for an Object which displays a flat color.
Dynamic textures material with PBR and lightmap support.
L1 Spherical Harmoics shader.
std::vector< uint8_t > getMeshletTriangles() const
float getBoundingSphereRadius() const
ApplicationContext * context
std::vector< meshopt_Meshlet > getMeshlets() const
std::vector< Vertex > getVertices() const
PipelineNames getMaterialName() const
std::variant< NormalMaterialData, DiffuseFlatColorMaterialData, DiffuseShaderMaterialData, MovableDiffuseShaderMaterialData, L0ShaderMaterialData, L1ShaderMaterialData, L2ShaderMaterialData, DynamicTexturesMaterialData, StaticLightmapMaterialData > materialData
uint32_t getTextureIndex() const
ObjectCullingData objectCullingData
const std::vector< uint32_t > & getIndicesByRef() const
const std::vector< MeshletBounds > & getMeshletBoundsByRef() const
uint32_t getMeshletTriangleCount() const
std::vector< uint32_t > meshletVertices
const std::vector< Vertex > & getVerticesByRef() const
std::vector< Vertex > vertices
const std::vector< uint32_t > & getMeshletVerticesByRef() const
void setMaterialShader(MaterialShader *shader)
std::vector< uint32_t > getIndices() const
std::vector< meshopt_Meshlet > meshlets
std::vector< MeshletBounds > meshletBounds
std::vector< uint8_t > meshletTriangles
const std::variant< NormalMaterialData, DiffuseFlatColorMaterialData, DiffuseShaderMaterialData, MovableDiffuseShaderMaterialData, L0ShaderMaterialData, L1ShaderMaterialData, L2ShaderMaterialData, DynamicTexturesMaterialData, StaticLightmapMaterialData > & getMaterialData() const
MaterialShader * materialShader
const ObjectCullingData & getPrimitiveBoundsByRef() const
uint32_t getMeshletVertexCount() const
uint32_t getMeshletsCount() const
const std::vector< uint8_t > & getMeshletTrianglesByRef() const
MaterialShader * getMaterialShader() const
void setMaterialId(uint32_t materialId)
std::vector< uint32_t > getMeshletVertices() const
std::vector< uint32_t > indices
const std::vector< meshopt_Meshlet > & getMeshletByRef() const
glm::vec3 getBoundingSphereCenter() const
ObjectCullingData getCullingData() const
Moveable diffuse shader with PBR and lightmap support.
Material data for an object which displays its normals.
The renderer is the main class for rendering. It owns all data which is used any time in any frame....
Definition Renderer.h:72
Static lightmap material with PBR support.
Log category system implementation.
Stores intermediate data from loading the asset from disk. These are the vertices,...
Definition GltfLoader.h:350
MeshletBounds getBounds(const std::vector< meshopt_Meshlet > &meshlets, const std::vector< Vertex > &vertices, const std::vector< uint32_t > &meshletVertices) const
Used in meshlet culling.
Definition RenderData.h:92
Data for object culling.
Definition RenderData.h:144