SpiecsEngine
 
Loading...
Searching...
No Matches
TransformComponent.h
Go to the documentation of this file.
1/**
2* @file TransformComponent.h.
3* @brief The TransformComponent Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "Component.h"
10#include "Core/Math/Transform.h"
11
12#define GLM_FORCE_RADIANS
13#include <glm/glm.hpp>
14#include <glm/gtc/matrix_transform.hpp>
15#include <glm/gtc/type_ptr.hpp>
16
17namespace Spices {
18
19 /**
20 * @brief Forward Declare.
21 */
22 class VulkanBuffer;
23
24 /**
25 * @brief TransformComponent Class.
26 * This class defines the specific behaves of TransformComponent.
27 */
29 {
30 public:
31
33 {
34 Clean = 0,
36 MAX = 0x7FFFFFFF
37 };
38
39 typedef uint32_t TransformComponentFlags;
40
41 public:
42
43 /**
44 * @brief Constructor Function.
45 */
47
48 /**
49 * @brief Destructor Function.
50 */
51 virtual ~TransformComponent() override = default;
52
53 /**
54 * @brief This interface defines how to serialize.
55 * @todo Finish it.
56 */
57 virtual void OnSerialize() override;
58
59 /**
60 * @brief This interface defines how to deserialize.
61 * @todo Finish it.
62 */
63 virtual void OnDeSerialize() override;
64
65 /**
66 * @brief This interface defines how to draw this component to property panel.
67 */
68 virtual void DrawThis() override;
69
70 /**
71 * @brief Set the position this component handled.
72 * Call CalMatrix() during this API.
73 * @param[in] position The entity's world position.
74 */
75 void SetPosition(const glm::vec3& position) { m_Transform.position = position; CalMatrix(); }
76
77 /**
78 * @brief Set the rotation this component handled.
79 * Call CalMatrix() during this API.
80 * @param[in] rotation The entity's world rotation.
81 */
82 void SetRotation(const glm::vec3& rotation) { m_Transform.rotation = rotation; CalMatrix(); }
83
84 /**
85 * @brief Set the scale this component handled.
86 * Call CalMatrix() during this API.
87 * @param[in] scale The entity's world scale.
88 */
89 void SetScale(const glm::vec3& scale) { m_Transform.scale = scale; CalMatrix(); }
90
91 /**
92 * @brief Add the position to this component handled.
93 * Call CalMatrix() during this API.
94 * @param[in] position The entity's world position.
95 */
96 void AddPosition(const glm::vec3& position) { m_Transform.position += position; CalMatrix(); }
97
98 /**
99 * @brief Add the rotation to this component handled.
100 * Call CalMatrix() during this API.
101 * @param[in] rotation The entity's world rotation.
102 */
103 void AddRotation(const glm::vec3& rotation) { m_Transform.rotation += rotation; CalMatrix(); }
104
105 /**
106 * @brief Add the scale to this component handled.
107 * Call CalMatrix() during this API.
108 * @param[in] scale The entity's world scale.
109 */
110 void AddScale(const glm::vec3& scale) { m_Transform.scale += scale; CalMatrix(); }
111
112 /**
113 * @brief Get the modelMatrix variable.
114 * @return Returns the modelMatrix variable.
115 */
116 const glm::mat4& GetModelMatrix() { CalMatrix(); return m_ModelMatrix; }
117
118 /**
119 * @brief Get Rotate Matrix.
120 * @return Returns the Rotate Matrix.
121 */
122 glm::mat4 GetRotateMatrix() const;
123
124 /**
125 * @brief Get the position variable.
126 * @return Returns the position variable.
127 */
128 const glm::vec3& GetPosition() const { return m_Transform.position; }
129
130 /**
131 * @brief Get the rotation variable.
132 * @return Returns the rotation variable.
133 */
134 const glm::vec3& GetRotation() const { return m_Transform.rotation; }
135
136 /**
137 * @brief Get the scale variable.
138 * @return Returns the scale variable.
139 */
140 const glm::vec3& GetScale() const { return m_Transform.scale; }
141
142 /**
143 * @brief Get WorldMarkFlags this frame.
144 * @return Returns the TransformComponentFlags.
145 */
146 inline TransformComponentFlags GetMarker() const { return m_Marker; }
147
148 /**
149 * @brief Mark TransformComponentFlags with flags.
150 * @param[in] flags In flags.
151 */
152 void Mark(TransformComponentFlags flags) { m_Marker |= flags; }
153
154 /**
155 * @brief Clear TransformComponentFlags with flags.
156 * @param[in] flags In flags.
157 */
159
160 /**
161 * @brief Get Model Buffer Address.
162 * @return Returns the Model Buffer Address.
163 */
164 uint64_t GetModelBufferAddress() const;
165
166 private:
167
168 /**
169 * @brief Calculate Model Matrix.
170 */
171 void CalMatrix();
172
173 private:
174
175 /**
176 * @brief The modelMatrix this component handled.
177 */
179
180 /**
181 * @brief The transform this component handled.
182 */
184
185 /**
186 * @brief World State this frame.
187 */
189
190 /**
191 * @brief Model Buffer.
192 */
193 std::shared_ptr<VulkanBuffer> m_ModelBuffer;
194 };
195}
#define ASSERT(expr)
Assert macro.
Definition Core.h:29
int main()
Main Function.
Definition EntryPoint.h:15
#define PROCESS_INSTANCE_ENTRY
Macros of modify Process instance state.
#define PROCESS_INSTANCE_EXIT
#define Update_F(item)
Definition MeshPack.h:92
std::string AftermathErrorMessage(GFSDK_Aftermath_Result result)
Helper for checking Nsight Aftermath failures.
bool operator<(const GFSDK_Aftermath_ShaderDebugInfoIdentifier &lhs, const GFSDK_Aftermath_ShaderDebugInfoIdentifier &rhs)
Helper for comparing GFSDK_Aftermath_ShaderDebugInfoIdentifier.
#define SPICES_PROFILE_ZONE
#define VK_FUNCTION_POINTER(function)
Macro for declare function pointer variable in VulkanFunctions.
#define VMA_ALLOCATOR
Use VMA for memory allocate.
Definition VulkanUtils.h:27
Application(const Application &)=delete
Copy Constructor Function.
virtual ~Application()
Destructor Function.
Application & operator=(const Application &)=delete
Copy Assignment Operation.
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
Definition Application.h:20
virtual void DrawThis() override
This interface defines how to draw this component to property panel.
virtual void OnDeSerialize() override
This interface defines how to deserialize.
bool m_IsActive
True if the camera is primary.
std::shared_ptr< Camera > GetCamera()
Get the camera variable.
virtual ~CameraComponent() override=default
Destructor Function.
CameraComponent(bool isActive=false)
Constructor Function. Init class variable. Usually call it.
virtual void OnSerialize() override
This interface defines how to serialize.
void SetCamera(std::shared_ptr< Camera > camera)
Set the camera this component handled.
std::shared_ptr< Camera > m_Camera
The camera this component handled.
bool IsActive() const
Query whether this camera is primary.
CameraComponent Class. This class defines the specific behaves of CameraComponent.
unsigned int m_StableFrames
Camera Stable Frames Number.
Definition Camera.h:174
void CalculatePMatrixReverseZ()
Calculate Projection Matrix by parameter.
Definition Camera.cpp:94
const glm::mat4 GetPMatrix() const
Get camera projection matrix.
Definition Camera.cpp:67
OrthographicParam m_OrthographicParam
Camera OrthographicParam.
Definition Camera.h:184
void SetOrthographic(float left, float right, float top, float bottom, float nearPlane, float farPlane)
Set ProjectionMatrix by using orthographic type.
Definition Camera.cpp:35
const ProjectionType & GetProjectionType() const
Get camera projection type.
Definition Camera.h:124
void SetPerspective(float aspectRatio)
Set ProjectionMatrix by using perspective type with one param.
Definition Camera.cpp:26
OrthographicParam & GetOrthographicParam()
Get OrthographicParam.
Definition Camera.h:148
Camera()=default
Constructor Function.
void SetPerspective(float fov, float nearPlane, float aspectRatio=1.777f)
Set ProjectionMatrix by using perspective type.
Definition Camera.cpp:15
glm::mat4 m_ProjectionMatrix
ProjectionMatrix. Init with identity Matrix.
Definition Camera.h:163
void IncreaseStableFrames()
InCreate 1 to m_StableFrames per frame.
Definition Camera.h:105
void ResetStableFrames()
Reset m_StableFrames to 0.
Definition Camera.cpp:49
float GetAspectRatio() const
Get camera AspectRatio.
Definition Camera.h:130
ProjectionType m_ProjectionType
Definition Camera.h:169
unsigned int GetStableFrames() const
Get camera StableFrames.
Definition Camera.h:136
PerspectiveParam m_PerspectiveParam
Camera PerspectiveParam.
Definition Camera.h:179
PerspectiveParam & GetPerspectiveParam()
Get PerspectiveParam.
Definition Camera.h:142
const glm::mat4 & GetPMatrixReverseZ()
Get camera reverse z projection matrix.
Definition Camera.h:111
virtual ~Camera()=default
Destructor Function.
Camera Class. This class just encapsulate Projection Matrix.
Definition Camera.h:59
entt::entity m_Owner
This component's Owner entity.
Definition Component.h:67
Component()=default
Constructor Function.
virtual void OnDeSerialize()=0
This interface defines how to deserialize.
virtual void OnSerialize()=0
This interface defines how to serialize.
virtual void OnComponentAdded(const entt::entity &entity)
This interface defines the behaves on specific component added. Init with variable.
Definition Component.cpp:17
virtual ~Component()=default
Destructor Function.
virtual void DrawThis()
This interface defines how to draw this component to property panel.
Definition Component.h:60
Component Class. This class defines the basic behaves of component. When we add an new Component,...
Definition Component.h:27
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:359
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:486
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:481
CubePack(uint32_t rows=2, uint32_t columns=2, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:456
virtual ~CubePack() override=default
Destructor Function.
CubePack Class. This class defines box type mesh pack.
Definition MeshPack.h:446
Entity Class. This class defines the specific behaves of Entity.
Definition Entity.h:20
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:551
virtual ~FilePack() override=default
Destructor Function.
FilePack(const std::string &filePath, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:551
std::string m_Path
The mesh file path in disk.
Definition MeshPack.h:575
FilePack Class. This class defines file type mesh pack.
Definition MeshPack.h:542
static void CrashDumpDescriptionCallback(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription, void *pUserData)
GPU crash dump description callback.
static void Init()
Create single instance of this class.
static constexpr unsigned int c_MarkerFrameHistory
keep four frames worth of marker history.
void WriteShaderDebugInformationToFile(GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier, const void *pShaderDebugInfo, const uint32_t shaderDebugInfoSize) const
Helper for writing shader debug information to a file.
void SetMarker(uint64_t &markerId, const std::string &info)
Set Marker.
MarkerMap m_MarkerMap
App-managed marker tracking.
void OnShaderLookup(const GFSDK_Aftermath_ShaderBinaryHash &shaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary) const
Handler for shader lookup callbacks. This is used by the JSON decoder for mapping shader instruction ...
void SetFrameCut(uint64_t frameCut)
Set FrameCut.
static void OnDescription(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription)
Handler for GPU crash dump description callbacks.
virtual ~GpuCrashTracker()
Destructor Function.
static void ShaderSourceDebugInfoLookupCallback(const GFSDK_Aftermath_ShaderDebugName *pShaderDebugName, PFN_GFSDK_Aftermath_SetData setShaderBinary, void *pUserData)
Shader source debug info lookup callback.
static void AftermathDeviceLostCheck()
Aftermath handle device lost function.
void OnResolveMarker(const void *pMarkerData, const uint32_t markerDataSize, void **ppResolvedMarkerData, uint32_t *pResolvedMarkerDataSize)
Handler for app-managed marker resolve callback.
std::mutex m_Mutex
For thread-safe access of GPU crash tracker state.
static std::unique_ptr< GpuCrashTracker > m_GpuCrashTracker
GpuCrashTracker single instance.
static void ShaderDebugInfoCallback(const void *pShaderDebugInfo, const uint32_t shaderDebugInfoSize, void *pUserData)
Shader debug information callback.
bool m_Initialized
Is the GPU crash dump tracker initialized?
std::array< std::map< uint64_t, std::string >, c_MarkerFrameHistory > MarkerMap
static void ShaderDebugInfoLookupCallback(const GFSDK_Aftermath_ShaderDebugInfoIdentifier *pIdentifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, void *pUserData)
Shader debug information lookup callback.
void OnCrashDump(const void *pGpuCrashDump, const uint32_t gpuCrashDumpSize)
Handler for GPU crash dump callbacks from Nsight Aftermath.
void OnShaderDebugInfo(const void *pShaderDebugInfo, const uint32_t shaderDebugInfoSize)
Handler for shader debug information callbacks.
void Initialize()
Initialize the GPU crash dump tracker.
static void GpuCrashDumpCallback(const void *pGpuCrashDump, const uint32_t gpuCrashDumpSize, void *pUserData)
GPU crash dump callback.
static GpuCrashTracker & Get()
Get single instance of this class.
ShaderDataBase m_ShaderDataBase
The mock shader database.
ShaderDataBase & GetShaderDataBase()
Get ShaderDataBase.
void OnShaderSourceDebugInfoLookup(const GFSDK_Aftermath_ShaderDebugName &shaderDebugName, PFN_GFSDK_Aftermath_SetData setShaderBinary) const
Handler for shader source debug info lookup callbacks. This is used by the JSON decoder for mapping s...
void WriteGpuCrashDumpToFile(const void *pGpuCrashDump, const uint32_t gpuCrashDumpSize)
Helper for writing a GPU crash dump to a file.
static void ResolveMarkerCallback(const void *pMarkerData, const uint32_t markerDataSize, void *pUserData, void **ppResolvedMarkerData, uint32_t *pResolvedMarkerDataSize)
App-managed marker resolve callback.
void OnShaderDebugInfoLookup(const GFSDK_Aftermath_ShaderDebugInfoIdentifier &identifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo) const
Handler for shader debug information lookup callbacks. This is used by the JSON decoder for mapping s...
static void ShaderLookupCallback(const GFSDK_Aftermath_ShaderBinaryHash *pShaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary, void *pUserData)
Shader lookup callback.
Implements GPU crash dump tracking using the Nsight Aftermath API.
static bool S_DragScalarN(const char *label, ImGuiDataType data_type, void *p_data, int components, float v_speed=1.0f, const void *p_min=NULL, const void *p_max=NULL, const char *format=NULL, ImGuiSliderFlags flags=0)
Draw Drag Scale with different p_min p_max.
static void CustomMaterialImage(SlateImage *context, ImVec2 size)
Draw image with custom material.
static void SetFonts(FontMode fontmode=FontMode::FONT_PROPORTIONAL_SCALED)
Looking for TTF fonts, first on the VULKAN SDK, then Windows default fonts.
static void SetStyle()
Setting common style across samples.
static ImVec2 GetLineItemSize()
Get Line Width's Square Size.
static void MainMenuTitleSeparator()
Draw main menu titile separator.
static void DrawTreeProgressBar(const std::string &treeName, std::function< void()> progressFunc, std::function< void()> treeFunc)
Draw a stylized tree title bar.
static bool DrawResetIcon(const bool &isMove)
Draw Reset Icon.
static void DrawMaterial(const std::string &name, float width, const std::shared_ptr< Material > &material)
Draw a Material.
static void MainDockSpace(Side side=Side::Scene, float alpha=1.0f)
Begin a docking space.
static bool DrawMaterialConstParams(std::shared_ptr< Material > material, ImGuiDataType data_type, int components, const char *format, ConstantParams &value)
Draw ConstantParams.
static void DrawPropertyItem(const std::string &itemName, float columeWidth, std::function< void()> nameFunc, std::function< void()> valFunc)
Draw a single property.
static void Checkbox(bool *isChecked)
ImGuiHelper Style Checkbox.
static float GetDPIScale()
Get GLFW DPI Scale.
static void DrawTreeTitle(const std::string &treeName, std::function< void()> optionFunc, std::function< void()> treeFunc)
Draw a stylized tree title bar.
The ImGuiH Class. This class defines helper function for slate render.
Definition ImguiHelper.h:61
static std::vector< VkVertexInputAttributeDescription > GetAttributeDescriptions()
Get VkVertexInputAttributeDescription for IA.
Definition Vertex.cpp:25
static std::vector< VkVertexInputBindingDescription > GetBindingDescriptions()
Get VkVertexInputBindingDescription for IA.
Definition Vertex.cpp:12
static std::vector< VkVertexInputAttributeDescription > GetSlateAttributeDescriptions()
Get Slate VkVertexInputAttributeDescription for IA.
Definition Vertex.cpp:60
static std::vector< VkVertexInputBindingDescription > GetSlateBindingDescriptions()
Get Slate VkVertexInputBindingDescription for IA.
Definition Vertex.cpp:39
static std::shared_ptr< spdlog::logger > s_ClientLogger
Game Stage Logger.
Definition Log.h:80
static bool m_IsInitialized
Definition Log.h:28
static std::shared_ptr< spdlog::logger > s_CoreLogger
Engine Stage Logger.
Definition Log.h:75
static void Init()
Init Log.
Definition Log.cpp:24
static std::shared_ptr< spdlog::logger > & GetCoreLogger()
Get Engine Stage Logger.
Definition Log.h:46
static std::shared_ptr< spdlog::logger > & GetClientLogger()
Get Game Stage Logger.
Definition Log.h:52
static void PostHandle(format_string_t< Args... > fmt, Args &&...args)
Post handle with log message.
Definition Log.h:84
static void ShutDown()
Shutdown Log.
Definition Log.cpp:82
static bool SaveDefaultMaterial()
Test function.
static bool Load(const std::string &fileName, Material *outMaterial)
Public called API, it is entrance.
static bool LoadFromSASSET(const std::string &fileName, Material *outMaterial)
Load data from a .sasset file.
static bool LoadFromMaterial(const std::string &fileName, Material *outMaterial)
Load data from a .material file.
This enum defines tree types of material file.
virtual ~MaterialProperties()=default
Destructor Function.
MaterialProperties()
Constructor Function.
Wrapper of material render options.
void BuildMaterial(bool isAutoRegistry=true)
This interface need to be overwritten by specific material. It defines how we build texture and descr...
Definition Material.cpp:136
void PushToTextureParams(const std::string &name, const TextureParam &texture)
Push item to ShaderPath.
Definition Material.cpp:101
const std::vector< std::string > & GetShaderPath(const std::string &stage)
Get material shader path.
Definition Material.cpp:76
scl::linked_unordered_map< std::string, ConstantParams > m_ConstantParams
Constant parameters. Key: parameter name, Value: parameter value.
Definition Material.h:226
T GetDefaultConstantParams(const std::string &name)
Get default material constant parameter.
Definition Material.h:261
bool m_AlreadyBuild
True if this material already build a buffer.
Definition Material.h:252
const std::unordered_map< std::string, std::vector< std::string > > & GetShaderPath() const
Get material shader path.
Definition Material.h:111
void UpdateMaterial()
Update material data to buffer.
Definition Material.cpp:369
std::unordered_map< std::string, std::vector< std::string > > m_Shaders
Shader path Key: shader usage, Value: shader file name.
Definition Material.h:212
void Deserialize()
Deserialize the data from a disk file(.material) to this class.
Definition Material.cpp:63
void PushToShaderPath(const std::string &name, const std::string &shader)
Push item to ShaderPath.
Definition Material.cpp:91
std::unordered_map< std::string, std::vector< std::string > > m_DefaultShaders
Definition Material.h:213
void PushToConstParams(const std::string &name, const ConstantParam &param)
Push item to ConstParams.
Definition Material.cpp:111
uint64_t GetMaterialParamsAddress() const
Get material parameter address on GPU.
Definition Material.cpp:120
const std::string & GetName() const
Get Material Path.
Definition Material.h:98
scl::runtime_memory_block m_Buffermemoryblocks
m_Buffers's c++ data container. Key: set, Value: scl::runtime_memory_block.
Definition Material.h:232
Material()=default
Constructor Function.
scl::linked_unordered_map< std::string, TextureParam > m_DefaultTextureParams
Definition Material.h:220
bool GetIsDrawWindow() const
Get boolean of whether draw a material window.
Definition Material.h:170
void SetIsDrawWindow(bool isDrawWindow)
Set boolean of whether draw a material window.
Definition Material.h:176
scl::linked_unordered_map< std::string, TextureParam > & GetTextureParams()
Get material texture parameters.
Definition Material.h:117
void SetName(const std::string &path)
Set material path.
Definition Material.h:129
bool m_IsDrawWindow
True if this material needs to draw a window.
Definition Material.h:247
scl::linked_unordered_map< std::string, ConstantParams > & GetConstantParams()
Get material constant parameters.
Definition Material.h:123
Material(const std::string &materialPath)
Constructor Function. Deserialize immediately. Usually call it.
Definition Material.cpp:20
scl::linked_unordered_map< std::string, TextureParam > m_TextureParams
Texture parameters. Key: parameter name, Value: parameter value.
Definition Material.h:219
std::mutex m_Mutex
Mutex of this material.
Definition Material.h:257
virtual ~Material()
Destructor Function.
Definition Material.cpp:33
std::unique_ptr< VulkanBuffer > m_MaterialParameterBuffer
Definition Material.h:237
MaterialProperties m_Properties
Properties of render options.
Definition Material.h:242
std::string m_MaterialPath
Definition Material.h:206
void Serialize()
Serialize this class data to a disk file(.material).
Definition Material.cpp:53
Material Class. This class contains a branch of parameter and shader, also descriptor.
Definition Material.h:62
MeshLoader Class. This class only defines static function for load data from mesh file.
Definition MeshLoader.h:48
AccelKHR m_Accel
This meshPack blas accel.
Definition MeshPack.h:368
UUID GetUUID() const
Get mesh pack UUID.
Definition MeshPack.h:235
std::optional< std::atomic_uint32_t > m_ShaderGroupHandle
specific shader group handle. Used in IndirectDGCPipeline.
Definition MeshPack.h:353
void SetHitShaderHandle(uint32_t handle)
Set hit shader Handle.
Definition MeshPack.h:212
std::string m_MeshPackName
MeshPack Name.
Definition MeshPack.h:321
uint32_t GetNTasks() const
Get NTasks.
Definition MeshPack.h:265
void OnDraw(const VkCommandBuffer &commandBuffer) const
Draw indexed.
Definition MeshPack.cpp:96
virtual bool OnCreatePack(bool isCreateBuffer=true)
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:119
MeshResource m_MeshResource
Mesh Resources.
Definition MeshPack.h:331
uint32_t GetShaderGroupHandle() const
Get ShaderGroup Handle, which accessed by gdc buffer.
Definition MeshPack.cpp:180
std::optional< std::atomic_uint32_t > m_HitShaderHandle
specific hit shader handle. Used in RayTracing Pipeline.
Definition MeshPack.h:347
void OnDrawMeshTasks(const VkCommandBuffer &commandBuffer) const
Draw Mesh Tasks.
Definition MeshPack.cpp:112
VkDrawMeshTasksIndirectCommandNV m_MeshTaskIndirectDrawCommand
Draw Command.
Definition MeshPack.h:383
MeshDesc & GetMeshDesc()
Get Mesh Description.
Definition MeshPack.h:271
const std::string & GetPackType() const
Get Pack Type.
Definition MeshPack.h:283
uint32_t GetHitShaderHandle() const
Get Hit Shader Handle, which accessed by ray gen shader.
Definition MeshPack.cpp:165
MeshPack(const std::string &name, bool instanced)
Constructor Function.
Definition MeshPack.cpp:78
bool HasBlasAccel()
Is this meshPack has a valid blas.
Definition MeshPack.cpp:251
std::string m_PackType
specific mesh pack type.
Definition MeshPack.h:363
void CreateBuffer()
Create Vertices buffer anf Indices buffer.
Definition MeshPack.cpp:278
VulkanRayTracing::BlasInput MeshPackToVkGeometryKHR()
Convert MeshPack into the ray tracing geometry used to build the BLAS.
Definition MeshPack.cpp:195
std::atomic_bool m_IsRequiredAccel
True if required accel by BLAS Build.
Definition MeshPack.h:373
void OnBind(const VkCommandBuffer &commandBuffer) const
Bind VBO and EBO.
Definition MeshPack.cpp:86
MeshDesc m_Desc
Mesh Description.
Definition MeshPack.h:358
std::shared_ptr< Material > GetMaterial()
Get material in this class.
Definition MeshPack.h:206
const VkDrawMeshTasksIndirectCommandNV & GetDrawCommand() const
Get Draw Command.
Definition MeshPack.h:277
void SetMaterial(std::shared_ptr< Material > material)
Set specific material for this class.
Definition MeshPack.cpp:155
MeshPack & operator=(const MeshPack &)=delete
Copy Constructor Function.
void SetShaderGroupHandle(uint32_t handle)
Set hit shader Handle.
Definition MeshPack.h:218
const MeshResource & GetResource() const
Get Resource.
Definition MeshPack.h:307
std::shared_ptr< Material > m_Material
specific material pointer.
Definition MeshPack.h:341
void SetMaterial(const std::string &materialPath)
Set specific material for this class.
Definition MeshPack.cpp:145
uint32_t m_NTasks
Task Shader Work Group Size.
Definition MeshPack.h:336
virtual ~MeshPack()=default
Destructor Function.
UUID m_UUID
UUID for mesh pack.
Definition MeshPack.h:378
const std::vector< Meshlet > & GetMeshlets() const
Get Meshlets array.
Definition MeshPack.h:259
MeshPack(const MeshPack &)=delete
Copy Constructor Function.
bool m_Instanced
If this mesh pack needs instanced.
Definition MeshPack.h:326
AccelKHR & GetAccel()
Get this accel.
Definition MeshPack.cpp:261
MeshPack Class. This class defines some basic behaves and variables. This class need to be inherited ...
Definition MeshPack.h:156
static bool PackPrimVerticesFromSparseInputs(MeshPack *meshPack, const std::vector< glm::uvec3 > primVertices, std::vector< glm::vec3 > &packPoints, std::vector< glm::uvec3 > &packPrimPoints, std::unordered_map< uint32_t, uint32_t > &primVerticesMapReverse)
Pack PrimVertices from Sparse PrimVertices Inputs.
static SpicesShader::Sphere CalculateBoundSphere(const std::vector< glm::vec3 > &points)
Calculate BoundSphere from Points.
static bool FindBoundaryPoints(MeshPack *meshPack, const std::vector< glm::uvec3 > &primVertices, std::unordered_map< uint32_t, bool > &boundaryPoints, std::unordered_map< uint32_t, bool > &stableBoundaryPoints, std::unordered_map< uint32_t, EdgePoint > &boundaryEdgePoints, std::unordered_map< uint32_t, std::unordered_map< uint32_t, bool > > &pointConnect)
Find Points located in Boundaries.
static bool MergeByDistance(MeshPack *meshPack, std::vector< glm::uvec3 > &primVertices, scl::kd_tree< 6 > &kdTree, float maxDistance, float maxUVDistance)
Merge Vertex by Distance.
static void GenerateMeshLodClusterHierarchy(MeshPack *meshPack)
Generate Mesh Lod Resources.
static bool PackVertexToPoints(MeshPack *meshPack, const std::vector< glm::uvec3 > &primVertices, std::vector< glm::vec3 > &points)
Pack Vertices to Points.
static bool UnPackPrimVerticesToSparseInputs(std::vector< glm::uvec3 > &primVertices, std::unordered_map< uint32_t, uint32_t > &primVerticesMapReverse, const std::vector< glm::uvec3 > &packPrimPoints)
Unpack PrimVertices to Sparse PrimVertices Inputs.
static void AppendMeshlets(MeshPack *meshPack, uint32_t lod, const SpicesShader::Sphere &clusterBoundSphere, const std::vector< glm::uvec3 > &primVertices)
Create and Append Meshlets to MeshPack use given indices.
static std::vector< MeshletGroup > GroupMeshlets(MeshPack *meshPack, std::vector< Meshlet > &meshlets)
Split Meshlets to Groups.
static bool BuildKDTree(MeshPack *meshPack, const std::vector< glm::uvec3 > &primVertices, scl::kd_tree< 6 > &kdTree)
Build KDTree use specific meshlets.
Class for provide functions of process Meshpack.
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:437
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:432
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:315
PlanePack(uint32_t rows=2, uint32_t columns=2, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:407
virtual ~PlanePack() override=default
Destructor Function.
PlanePack Class. This class defines plane type mesh pack.
Definition MeshPack.h:397
ResourcePool()=default
Constructor Function.
ResourcePool & operator=(const ResourcePool &)=delete
Copy Constructor Function.
static bool Has(const std::string &name)
Determine if specific resource is exist.
static std::shared_ptr< T > Load(const std::string &path, Args... args)
Load a resource by path. When we need a resource, we call this API. Load if resource is not found.
static void Registry(const std::string &name, std::shared_ptr< T > resource)
Registry a resource to this Pool.
static void Destroy()
Destroy this resource pool. Release all Resource Pointer, which means resource can be destructed afte...
ResourcePool(const ResourcePool &)=delete
Copy Constructor Function.
virtual ~ResourcePool()=default
Destructor Function.
static void UnLoad(const std::string &path)
UnLoad a resource by path.
static std::shared_ptr< T > Access(const std::string &path)
Access a resource by path directly. Do nothing if resource is not found.
static std::unordered_map< std::string, std::unique_ptr< Resource > > m_Resources
Static variable stores all specific resources in a basic type Pool.
static std::shared_mutex m_Mutex
Mutex for this pool.
Template ResourcePool Class. This class will assign Every Type of Resource per Pool....
virtual ~Resource()
Unload resource.
Definition Resource.h:57
Resource(std::function< std::any()> fn)
Constructor Function.
Definition Resource.h:38
std::any m_Resource
Resource instance wrapper.
Definition Resource.h:94
void UnLoad()
UnLoad this resource.
Definition Resource.h:112
std::function< std::any()> m_CreateFunction
Resource create function.
Definition Resource.h:104
ResourceStateEnum
Enum of ResourceState.
Definition Resource.h:25
std::shared_ptr< T > GetResource()
Get resource instance.
Definition Resource.h:137
ResourceStateEnum m_State
Resource state.
Definition Resource.h:99
std::mutex m_Mutex
Mutex of this resource.
Definition Resource.h:109
ResourceStateEnum GetState() const
Get resource state.
Definition Resource.h:68
void CreateResource()
Create resource instance.
Definition Resource.h:123
Resource Wrapper of ResourceInstance.
Definition Resource.h:18
static VkShaderStageFlagBits ToFlagBits(ShaderStage stage)
Convert ShaderStage to VkShaderStageFlagBits.
static std::string ToString(ShaderStage stage)
Convert ShaderStage to String.
static shaderc_shader_kind ToShaderCKind(ShaderStage stage)
Convert ShaderStage to shaderc_shader_kind.
static ShaderStage ToStage(std::string stage)
Convert String to ShaderStage.
ShaderHelper Class.
Slate image draw context.
Definition SlateImage.h:18
SpherePack(uint32_t rows=15, uint32_t columns=24, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:504
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:529
virtual ~SpherePack() override=default
Destructor Function.
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:563
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:534
SpherePack Class. This class defines sphere type mesh pack.
Definition MeshPack.h:494
Texture2DCube Class. This class defines the basic behaves of Texture2DCube.
Texture2D(const RendererResourceCreateInfo &info)
Constructor Function. Used for create render resource.
Definition Texture2D.cpp:15
Texture2D(const std::string &path)
Constructor Function. Init class variable, load date immediately. Usually call it.
Definition Texture2D.cpp:93
virtual ~Texture2D() override=default
Destructor Function.
Texture2D()=default
Constructor Function.
Texture2D Class. This class defines the basic behaves of texture2D.
Definition Texture2D.h:20
static void Load(const std::string &fileName, Texture2DCube *outTexture)
Load image to a Texture2DCube object.
static void Load(const std::string &fileName, Texture2D *outTexture)
Load image to a Texture2D object.
static bool LoadSrc(const std::string &fileName, const std::string &it, Texture2D *outTexture, bool isCreateCompressTexture=true)
Function of load a src file.
static bool SearchFile(const std::string &fileName, std::function< void(const std::string &)> binF, std::function< void(const std::string &)> srcF)
Search texture file and load.
static bool LoadBin(const std::string &fileName, const std::string &it, Texture2D *outTexture)
Function of load a ktx file.
TextureLoader Class. This class only defines static function for load data from image file.
virtual ~Texture()=default
Destructor Function.
std::string m_ResourcePath
Texture's path in disk.
Definition Texture.h:74
Texture(const std::string &path)
Constructor Function. Init class variable. Usually call it.
Definition Texture.h:47
Texture()=default
Constructor Function.
std::shared_ptr< T > GetResource()
Get Specific resource, usually is a wrapper of VulkanImage.
Definition Texture.h:78
std::any m_Resource
Texture's resource, coule be any kind of type.
Definition Texture.h:68
Texture Class. This class defines the basic behaves of texture. When we add an new Texture,...
Definition Texture.h:33
static bool SetThreadName(const std::string &name)
Set Thread name.
Thread Static Function Library.
void Continue()
Continue ThreadPool.
bool m_IsSuspend
True if needs suspend on executing the task.
const int GetIdleThreadSize() const
GetIdleThreadSize. This function is just used for unit test, should not be used in engine.
std::atomic_int m_IdleThreadSize
Idled thread size.
std::queue< Task > m_TaskQueue
Task Queue.
void SetThreadIdleTimeOut(int idleTime)
Set Pool Threads idle time out.
std::atomic_int m_Tasks
Number of tasks;.
std::condition_variable m_ExitCond
Thread pool Exit Condition.
PoolMode m_PoolMode
Thread Pool Run Mode.
bool CheckRunningState() const
Check whether this pool is still in running.
const bool IsPoolRunning() const
GetIsPoolRunning. This function is just used for unit test, should not be used in engine.
void SetMode(PoolMode mode)
Set Pool Run Mode.
std::mutex m_Mutex
Mutex for thread safe.
const int GetThreadsCount() const
Get Threads Count. This function is just used for unit test, should not be used in engine.
virtual ~ThreadPool_Basic()
Destructor Function.
const PoolMode & GetPoolMode() const
GetPoolMode. This function is just used for unit test, should not be used in engine.
std::unordered_map< uint32_t, std::unique_ptr< Thread< Params... > > > m_Threads
Threads Container.
ThreadPool_Basic(const std::string &name="NonNameT")
Constructor Function.
void Suspend()
Suspend ThreadPool.
void Start(int initThreadSize=0.5 *std::thread::hardware_concurrency())
Start Run this thread pool.
const int GetTasks() const
Get TaskQueue Count. This function is just used for unit test, should not be used in engine.
std::string m_PoolName
This ThreadPool Name.
ThreadPool_Basic & operator=(const ThreadPool_Basic &)=delete
Copy Assignment Operation.
std::condition_variable m_NotEmpty
Task Queue not empty.
uint32_t m_InitThreadSize
Initialized thread size.
auto SubmitPoolTask(Func &&func, Args &&... args) -> std::future< decltype(func(std::forward< Args >(args)...))>
Submit a task to task queue, and wait for a idle thread to execute it.
void ThreadFunc(Thread<> *thread)
Thread Function.
uint32_t m_ThreadIdleTimeOut
thread idle time out.
const std::unordered_map< uint32_t, std::unique_ptr< Thread< Params... > > > & GetThreads() const
Get Threads. This function is just used for unit test, should not be used in engine.
std::atomic_int m_NThreads
Threads Count.
ThreadPool_Basic(const ThreadPool_Basic &)=delete
Copy Constructor Function.
std::condition_variable m_IdleCond
Thread pool thread idle Condition.
void SubmitThreadTask_LightWeight(uint32_t threadId, std::function< void(Params...)> func)
Submit a task to specific thread.
void SubmitThreadTask_LightWeight_ForEach(std::function< void(Params...)> func)
Submit a task to all thread.
const int GetThreadIdleTimeOut() const
ThreadIdleTimeOut. This function is just used for unit test, should not be used in engine.
void Wait()
Wait for all tasks executed finish in taskqueue.
std::atomic_bool m_IsPoolRunning
True if this thread pool is in use.
const int GetInitThreadSize() const
GetInitThreadSize. This function is just used for unit test, should not be used in engine.
Thread Pool Basic Class. Instance inherited from it and use multithreading feature.
Thread & operator=(const Thread &)=delete
Copy Assignment Operation.
std::queue< ThreadTask > m_ThreadTasksQueue
Thread Tasks Queue.
void Start()
Start a thread to execute Thread Function.
virtual ~Thread()=default
Destructor Function.
std::atomic_int m_ThreadTasks
Thread Tasks Count.
Thread(const Thread &)=delete
Copy Constructor Function.
Thread(ThreadFunc func, uint32_t threadId)
Constructor Function.
void Wait() const
Wait for all thread tasks finished.
void SetThreadInTask(bool isInTask)
Set this Thread is in task or not.
void ReceiveThreadTask(std::function< void(Params...)> func)
Receive a task must execute by this thread.
uint32_t m_ThreadId
Thread Id.
uint32_t GetId() const
Get Thread Id.
bool GetThreadInTask() const
Get this Thread is in task or not.
int GetThreadTasksCount() const
Get Thread Tasks Count. @reutrn Returns the Thread Tasks Count.
ThreadFunc m_Func
Thread Function.
std::mutex m_Mutex
A Mutex for Thread.
std::atomic_bool m_IsInTask
True if this thread is executing a task.
auto RequireTask() -> ThreadTask
Get this mutex.
Thread Function Object.
float m_FrameTime
time step(s) during frames.
Definition TimeStep.h:85
std::chrono::steady_clock::time_point m_StartTime
Engine Start time.
Definition TimeStep.h:75
void Flush()
Refresh time in each engine loop.
Definition TimeStep.cpp:26
const float & ft() const
Get time step during frames.
Definition TimeStep.h:51
TimeStep(const TimeStep &)=delete
Copy Constructor Function.
const uint64_t & fs() const
Get frames count.
Definition TimeStep.h:63
TimeStep()
Constructor Function.
Definition TimeStep.cpp:12
virtual ~TimeStep()=default
Destructor Function.
std::chrono::steady_clock::time_point m_LastTime
Last frame time.
Definition TimeStep.h:80
float m_GameTime
time step(s) since Engine Start.
Definition TimeStep.h:90
uint64_t m_Frames
Frames since Engine Start.
Definition TimeStep.h:95
TimeStep & operator=(const TimeStep &)=delete
Copy Assignment Operation.
const float & gt() const
Get time step since Engine Start.
Definition TimeStep.h:57
This Class handles our engine time step during frames. Global Unique.
Definition TimeStep.h:22
static TracyGPUContext & Get()
Get this Single Instance.
static std::shared_ptr< TracyGPUContext > m_TracyGPUContext
This Single Instance.
virtual ~TracyGPUContext()=default
Destructor Function.
tracy::VkCtx * m_Context
Tracy Vulkan Context.
TracyGPUContext(VulkanState &state)
Constructor Function.
VulkanState & m_VulkanState
VulkanState.
tracy::VkCtx *& GetContext()
Get Context.
static void CreateInstance(VulkanState &state)
Create this Single Instance.
Wapper of Tracy GPU collect features.
glm::mat4 GetRotateMatrix() const
Get Rotate Matrix.
void ClearMarkerWithBits(TransformComponentFlags flags)
Clear TransformComponentFlags with flags.
virtual void OnSerialize() override
This interface defines how to serialize.
void AddScale(const glm::vec3 &scale)
Add the scale to this component handled. Call CalMatrix() during this API.
std::shared_ptr< VulkanBuffer > m_ModelBuffer
Model Buffer.
glm::mat4 m_ModelMatrix
The modelMatrix this component handled.
TransformComponentFlags m_Marker
World State this frame.
virtual void OnDeSerialize() override
This interface defines how to deserialize.
TransformComponentFlags GetMarker() const
Get WorldMarkFlags this frame.
void SetScale(const glm::vec3 &scale)
Set the scale this component handled. Call CalMatrix() during this API.
void CalMatrix()
Calculate Model Matrix.
const glm::vec3 & GetRotation() const
Get the rotation variable.
virtual void DrawThis() override
This interface defines how to draw this component to property panel.
void SetRotation(const glm::vec3 &rotation)
Set the rotation this component handled. Call CalMatrix() during this API.
TransformComponent()
Constructor Function.
Transform m_Transform
The transform this component handled.
void AddRotation(const glm::vec3 &rotation)
Add the rotation to this component handled. Call CalMatrix() during this API.
void AddPosition(const glm::vec3 &position)
Add the position to this component handled. Call CalMatrix() during this API.
const glm::vec3 & GetPosition() const
Get the position variable.
uint64_t GetModelBufferAddress() const
Get Model Buffer Address.
const glm::vec3 & GetScale() const
Get the scale variable.
const glm::mat4 & GetModelMatrix()
Get the modelMatrix variable.
void SetPosition(const glm::vec3 &position)
Set the position this component handled. Call CalMatrix() during this API.
void Mark(TransformComponentFlags flags)
Mark TransformComponentFlags with flags.
virtual ~TransformComponent() override=default
Destructor Function.
TransformComponent Class. This class defines the specific behaves of TransformComponent.
UUID()
Constructor Function.
Definition UUID.cpp:18
uint64_t m_UUID
UUID.
Definition UUID.h:52
UUID(uint64_t uuid)
Constructor Function.
Definition UUID.cpp:22
UUID(const UUID &)=default
Destructor Function.
std::string ToString()
Transform UUID to String.
Definition UUID.cpp:26
operator uint64_t() const
Operator Function.
Definition UUID.h:39
This class helps to generate a uuid for one resource.
Definition UUID.h:16
VkAccelerationStructureKHR & Get()
Get this wrapped VkAccelerationStructureKHR.
VkDeviceAddress GetACDeviceAddress() const
Get AC Buffer Address.
virtual ~VulkanAccelerationStructure() override
Destructor Function.
VulkanAccelerationStructure(VulkanState &vulkanState, VkAccelerationStructureCreateInfoKHR &accel)
Constructor Function. Create VkBuffer.
VkAccelerationStructureKHR m_Accel
This wrapped VkAccelerationStructureKHR.
This Class is a Wrapper of VkAccelerationStructure.
VkBufferUsageFlags m_Usage
The buffer usage.
VkMemoryPropertyFlags m_Flags
The buffer memory requirement flags.
VkBuffer m_Buffer
The buffer this class handled.
void CreateBuffer(VulkanState &vulkanState, const std::string &name, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties)
Create a buffer.
VulkanBuffer(VulkanState &vulkanState, const std::string &name, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties)
Constructor Function. Create VkBuffer.
VmaAllocation m_Alloc
VMA allocation.
uint64_t GetSize() const
Get Buffer Size.
void CopyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size)
Copy data from a buffer to another.
void WriteToBuffer(const void *data, VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
Write data to buffer.
VkDeviceSize m_DeviceSize
The buffer size.
VkDeviceAddress & GetAddress()
Get VkBuffer Address.
void Map(VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
Map buffer video memory to a local memory.
void WriteFromBuffer(void *data, VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
Write data from buffer.
VkDescriptorBufferInfo * GetBufferInfo(VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0)
Get VkDescriptorBufferInfo.
virtual ~VulkanBuffer() override
Destructor Function.
VkDescriptorBufferInfo m_BufferInfo
VkDescriptorBufferInfo.
std::string m_Name
Buffer Name.
VkDeviceAddress m_BufferAddress
The buffer gpu address.
VulkanBuffer(VulkanState &vulkanState)
Constructor Function. Create VkBuffer.
VkBuffer & Get()
Get VkBuffer.
void Flush(VkDeviceSize size=VK_WHOLE_SIZE, VkDeviceSize offset=0) const
Flush the buffer's video memory data.
This Class is a Wrapper of VulkanBuffer.
static void EndLabel(VkCommandBuffer cmdBuffer)
End Record Commands with a Label.
static void BeginLabel(VkCommandBuffer cmdBuffer, const std::string &caption, glm::vec4 color=glm::vec4(1.0f))
Start Record Commands with a Label.
static void BeginQueueLabel(VkQueue queue, const std::string &caption, glm::vec4 color=glm::vec4(1.0f))
Start Record Queue with a Label.
static void SetObjectName(VkObjectType type, uint64_t handle, VkDevice &device, const std::string &caption)
Set Vulkan Object with a name, which can be captured.
static void InsertQueueLabel(VkQueue queue, const std::string &caption, glm::vec4 color=glm::vec4(1.0f))
Insert Record Queue with a Label.
static void SetObjectTag(VkObjectType type, uint64_t handle, VkDevice &device, const std::vector< char * > &captions)
Set Vulkan Object with tags, which can be captured.
static void InsertLabel(VkCommandBuffer cmdBuffer, const std::string &caption, glm::vec4 color=glm::vec4(1.0f))
Insert Record Commands with a Label.
static void EndQueueLabel(VkQueue queue)
End Record Queue with a Label.
This Class Defines static function for helping vulkan debug.
VulkanObject(const VulkanObject &)=delete
Copy Constructor Function.
virtual ~VulkanObject()=default
Destructor Function. We destroy pipeline layout here.
VulkanObject & operator=(const VulkanObject &)=delete
Copy Assignment Operation.
VulkanState & m_VulkanState
The global VulkanState Referenced from VulkanRenderBackend.
VulkanObject(VulkanState &vulkanState)
Constructor Function. Init member variables.
VulkanObject Class. This class defines the basic behaves of VulkanObject. When we create an new Vulka...
VkPipelineShaderStageCreateInfo GetShaderStageCreateInfo() const
virtual ~VulkanShaderModule() override
Destructor Function.
std::string GetShaderPath(const std::string &name, const std::string &shaderType)
Get shader path string.
VkShaderModule m_ShaderModule
The VkShaderModule this class handled.
VkShaderModule & Get()
Get VkShaderModule this class handled.
VulkanShaderModule(VulkanState &vulkanState, const std::string &shaderName, const std::string &shaderStage)
Constructor Function. Create VkShaderModule.
VulkanShaderModule(VulkanState &vulkanState, const std::string &shaderName, const ShaderStage &shaderStage, const std::vector< uint8_t > &spirv, const std::string &fullPath)
Constructor Function. Create VkShaderModule.
This Class is a Wrapper of VkShaderModule.
static void CreateMeshEntity(World *world, const std::string &name, const std::shared_ptr< Mesh > &mesh, std::function< void(Entity &)> onAdded=nullptr)
Create Entity with MeshComponent. Lightweight for game thread.
static void CreateMeshEntity(World *world, const std::string &name, std::function< std::shared_ptr< Mesh >()> onMeshCreated, std::function< void(Entity &)> onAdded=nullptr)
Create Entity with a Basic MeshComponent Async.
World Functions Class.
WorldMarkFlags GetMarker() const
Get WorldMarkFlags this frame.
Definition World.h:119
void ViewComponent(const std::vector< uint32_t > &ranges, uint32_t floor, uint32_t ceil, F &&fn)
View all component in this world in ranges.
Definition World.h:309
uint32_t WorldMarkFlags
Definition World.h:53
void Mark(WorldMarkFlags flags)
Mark WorldMarkFlags with flags.
Definition World.h:125
Entity CreateEntity(const std::string &name="None")
Create a new empty entity in this world.
Definition World.cpp:13
void OnComponentAdded(Entity *entity, T &component)
Called On any Component Added to this world.
Definition World.h:386
void ReserMark()
Reset WorldMarkFlags to Clean.
Definition World.h:130
void ViewRoot(F &&fn)
View all root in this world.
Definition World.h:329
Entity CreateEmptyEntity(UUID uuid)
Definition World.cpp:85
Entity CreateEntityWithUUID(UUID uuid, const std::string &name="None")
Create a new empty entity with a uuid in this world.
Definition World.cpp:20
void ViewComponent(F &&fn)
View all component in this world.
Definition World.h:276
void ViewComponent(const std::vector< uint32_t > &ranges, F &&fn)
View all component in this world in ranges.
Definition World.h:293
virtual void OnDeactivate()=0
This interface defines the specific world behaves after on activated.
virtual ~World()=default
Destructor Function.
Entity QueryEntitybyID(uint32_t id)
Get World Entity by id(entt::entity).
Definition World.cpp:41
virtual void OnPreActivate()=0
This interface define the specific world behaves before on activated.
entt::registry m_Registry
This variable handles all entity.
Definition World.h:250
std::shared_mutex m_Mutex
Mutex for world.
Definition World.h:245
void DestroyEntity(Entity &entity)
Destroy a entity from this world.
Definition World.cpp:31
T & GetComponent(entt::entity e)
Get Component owned by this entity.
Definition World.h:353
@ FrushStableFrame
Definition World.h:48
@ MeshAddedToWorld
Definition World.h:47
@ NeedUpdateTLAS
Definition World.h:49
void RemoveComponent(entt::entity e)
Remove Component owned from this entity.
Definition World.h:366
WorldMarkFlags m_Marker
World State this frame.
Definition World.h:272
entt::registry & GetRegistry()
Get Registry variable.
Definition World.h:106
void RemoveFromRoot(Entity &entity)
Remove a entity from this world root.
Definition World.cpp:58
virtual void OnActivate(TimeStep &ts)=0
This interface define the specific world behaves on activated.
void AddToRoot(Entity &entity)
Add a entity to this world root.
Definition World.cpp:67
World()=default
Constructor Function.
std::unordered_map< UUID, entt::entity > m_RootEntityMap
This variable is a cache. @noto Not in use now.
Definition World.h:257
bool IsRootEntity(Entity &entity)
Determine if a entity is in root.
Definition World.cpp:76
void ClearMarkerWithBits(WorldMarkFlags flags)
Clear WorldMarkFlags with flags.
Definition World.cpp:48
bool HasComponent(entt::entity e)
If Component is owned by this entity or not.
Definition World.h:376
T & AddComponent(entt::entity e, Args &&... args)
Template Function. Used for add specific component to entity.
Definition World.h:343
World Class. This class defines the basic behaves of World. When we create an new world,...
Definition World.h:41
virtual ~kd_tree()
Destructor Function.
Definition KDTree.h:596
void insert_recursive_async(Node *&node, std::shared_ptr< std::vector< item > > points, Spices::ThreadPool *threadPool, int depth)
Recursive function to insert a point into the kd_tree async.
Definition KDTree.h:320
size_t size() const
Get KD Tree size.
Definition KDTree.h:237
kd_tree()
Constructor to initialize the kd_tree with a null root.
Definition KDTree.h:158
void insert_async(const std::vector< item > &points, Spices::ThreadPool *threadPool)
Insert a point into the kd_tree async. Start at the root, comparing the new point’s first dimension w...
Definition KDTree.h:608
void insert_recursive(Node *&node, std::shared_ptr< std::vector< item > > points, int depth)
Recursive function to insert a point into the kd_tree.
Definition KDTree.h:241
void print() const
Public function to print the kd_tree.
Definition KDTree.h:672
std::atomic_size_t m_Size
Sizes of this kd tree.
Definition KDTree.h:81
Node * m_Root
Pointer to the root node of the tree.
Definition KDTree.h:76
void insert(const std::vector< item > &points)
Insert a point into the kd_tree. Start at the root, comparing the new point’s first dimension with th...
Definition KDTree.h:602
void range_search_recursive(Node *node, const item &point, const item &condition, std::vector< item > &rangePoints, int depth) const
Recursive function to search for all nearest points in the kd_tree.
Definition KDTree.h:463
void deletenode_recursive(Node *node)
Delete all node created by this ke_tree.
Definition KDTree.h:563
bool search_recursive(Node *node, const item &point, int depth) const
Recursive function to search for a point in the kd_tree.
Definition KDTree.h:421
auto nearest_neighbour_search(const item &point, const item &condition) const -> item
Search for a nearest point in the kd_tree. Traverse the tree as in a normal search to find the leaf n...
Definition KDTree.h:629
auto range_search(const item &point, const item &condition) const -> std::vector< item >
Search for all points within given range. Start at the root. If the current node is within the range,...
Definition KDTree.h:660
bool search(const item &point) const
Search for a point in the kd_tree. Start at the root, comparing the search point’s first dimension wi...
Definition KDTree.h:623
void print_recursive(Node *node, int depth) const
Recursive function to print the kd_tree.
Definition KDTree.h:529
The kd_tree with K dimensions container Class. K the number of dimensions. Every node in the tree is ...
Definition KDTree.h:27
void erase(const K &key)
Remove a element inside the container if founded by key.
V * find_value(const K &key)
Find the value by key.
void clear()
Clear this container's data.
V * prev_value(const K &key)
Get the previous element by the key.
std::shared_mutex m_Mutex
Mutex for this container.
void for_each(F &&fn)
Iter the container in order.
linked_unordered_map()
Constructor Function.
std::unordered_map< K, V > m_Map
void push_back(const K &key, const V &value)
Add a element to this container.
V * end()
Get the end element of this container.
bool has_key(const K &key)
Determine whether the key is in the container.
size_t size()
The container's element size.
void for_each(F &fn)
Iter the container in order.
std::list< K > m_Keys
The container keeps iter in order.
virtual ~linked_unordered_map()=default
Destructor Function.
std::atomic_int m_Size
This container size.
bool has_equal_size()
Determine whether the container's element size is same.
V * next_value(const K &key)
Get the next element by the key.
V * first()
Get the first element of this container.
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
size_t bytes_
The bytes of the continue memory block handled.
bool has_value(const std::string &name)
Determine is item inside this container.
void for_each(const std::function< bool(const std::string &name, void *pt)> &fn) const
Iter the object_ and call explain_element() to filling data.
std::unordered_map< std::string, size_t > object_
The data information of the continue memory block handled. Data: parameter name - parameter position ...
void build()
Malloc a memory to begin_.
void add_element(const std::string &name, const std::string &type)
Add a element to object_, means a memory block will be occupied with given param type.
size_t item_location(const std::string &name)
Get item location in blocks.
size_t get_bytes() const
Get the bytes_.
virtual ~runtime_memory_block()
Destructor Function.
size_t size() const
Get the size of object_.
void * begin_
The begin pointer of the continue memory block handled.
void explain_element(const std::string &name, const T &value)
Fill in a memory with given data.
runtime_memory_block()=default
Constructor Function.
void * get_addr() const
Get the begin_.
T & get_value(const std::string &name)
Get value that explained by name.
The container is wrapper of a continue memory block. Used in Material::BuildMaterial(),...
void CenteredText(const char *label, const ImVec2 &size_arg)
Draw a center text.
ShaderStage
enum of shader stage.
static const char * memoryPoolNames[3]
MemoryPool's name.
Definition Core.h:43
Side
Where the slate's initialized pos.
Definition ImguiHelper.h:43
glm::mat4 OtrhographicMatrix(float left, float right, float top, float bottom, float nearPlane, float farPlane)
Calculate Otrhographic Matrix.
Definition Math.cpp:114
glm::mat4 PerspectiveMatrixInverseZ(float fov, float nearPlane, float aspectRatio)
Calculate Perspective Matrix(reverse z version).
Definition Math.cpp:127
FontMode
Slate Font Mode.
Definition ImguiHelper.h:32
@ FONT_MONOSPACED_SCALED
Definition ImguiHelper.h:35
@ FONT_FIXED
Definition ImguiHelper.h:33
@ FONT_PROPORTIONAL_SCALED
Definition ImguiHelper.h:34
PoolMode
ThreadPool Run Mode.
glm::mat4 PerspectiveMatrix(float fov, float nearPlane, float farPlane, float aspectRatio)
Calculate Perspective Matrix.
Definition Math.cpp:100
bool DecomposeTransform(const glm::mat4 &transform, glm::vec3 &outTranslation, glm::vec3 &outRotation, glm::vec3 &outScale)
Decompose matrix to split SRT transform.
Definition Math.cpp:15
TextureType
The enum of all Texture Type.
Definition Texture.h:20
std::shared_ptr< World > CreateWorld()
extern WorldCreation definition in Game.
Definition EntryPoint.cpp:6
static void HandleVkResult(VkResult result)
Handle VkResult Function.
Definition VulkanUtils.h:39
constexpr uint32_t THREAD_MAX_IDLE_TIME
constexpr uint32_t MaxFrameInFlight
Max In Flight Frame. 2 buffers are enough in this program.
Definition VulkanUtils.h:22
const uint32_t THREAD_MAX_THRESHHOLD
ProjectionType
This Struct defines camera projection type.
Definition Camera.h:18
@ Orthographic
orthographic
Definition Camera.h:27
@ Perspective
perspective
Definition Camera.h:22
std::string to_string(const GFSDK_Aftermath_ShaderDebugInfoIdentifier &identifier)
Convert GFSDK_Aftermath_ShaderDebugInfoIdentifier to string.
std::string to_string(GFSDK_Aftermath_Result result)
Convert GFSDK_Aftermath_Result to string.
std::string to_hex_string(T n)
Convert T to hex string.
std::shared_ptr< VulkanBuffer > buffer
Definition Attribute.h:19
std::shared_ptr< VulkanAccelerationStructure > accel
Definition Attribute.h:18
AccelStructure Wrapper.
Definition Attribute.h:17
void CreateBuffer(const std::string &name, VkBufferUsageFlags usage=0)
Create Attribute Buffer.
Definition Attribute.h:80
virtual ~Attribute()
Destructor Function.
Definition Attribute.h:71
std::shared_ptr< VulkanBuffer > buffer
Attribute Buffer.
Definition Attribute.h:54
std::shared_ptr< std::vector< T > > attributes
Attribute Data Array.
Definition Attribute.h:49
Attribute()
Constructor Function.
Definition Attribute.h:58
MeshResource's item template.
Definition Attribute.h:28
std::string paramType
Definition Material.h:38
This struct's data is defined from .material file.
Definition Material.h:37
ConstantParam value
Definition Material.h:47
ConstantParam max
Definition Material.h:54
ConstantParam defaultValue
Definition Material.h:48
ConstantParam min
Definition Material.h:51
This struct's data is defined from .material file.
Definition Material.h:46
uint32_t prev
datas.
Definition Vertex.h:223
EdgePoint(uint32_t prev, uint32_t self, uint32_t next)
Constructor Function.
Definition Vertex.h:205
uint32_t next
Definition Vertex.h:225
bool valid()
Determine whether this edge point is valid.
Definition Vertex.h:215
EdgePoint()
Constructor Function.
Definition Vertex.h:193
uint32_t self
Definition Vertex.h:224
EdgePoint Class. This class defines what EdgePoint data.
Definition Vertex.h:187
Edge()=default
Constructor Function.
bool operator==(const Edge &other) const
Destructor Function. @attemtion Why Destructor causes bug here.
Definition Vertex.h:117
Edge(uint32_t f, uint32_t s)
Constructor Function.
Definition Vertex.h:99
bool operator<(const Edge &other) const
Less Operation.
Definition Vertex.h:127
Edge Class. This class defines what Edge data.
Definition Vertex.h:86
bool operator<(const HalfEdge &other) const
Less Operation.
Definition Vertex.h:177
HalfEdge()=default
Constructor Function.
bool operator==(const HalfEdge &other) const
Destructor Function. @attemtion Why Destructor causes bug here.
Definition Vertex.h:168
HalfEdge(uint32_t f, uint32_t s)
Constructor Function.
Definition Vertex.h:150
HalfEdge Class. This class defines what HalfEdge data.
Definition Vertex.h:137
uint32_t meshletOffset
Definition MeshPack.h:31
uint32_t nMeshlets
Definition MeshPack.h:32
uint32_t nPrimitives
Definition MeshPack.h:30
uint32_t primVertexOffset
Definition MeshPack.h:29
Lod Data.
Definition MeshPack.h:28
MeshDesc()
Constructor Function.
Definition MeshPack.cpp:29
MeshDesc Copy() const
Copy a MeshDesc from this.
Definition MeshPack.cpp:61
uint64_t GetBufferAddress() const
Get m_Buffer's Address.
Definition MeshPack.cpp:71
Add Construction Functions to SpicesShader::MeshDesc.
Definition MeshPack.h:90
MeshResource()=default
Constructor Function.
TexCoords texCoords
Definition MeshPack.h:71
Positions positions
Declare value.
Definition MeshPack.h:68
PrimitiveVertices primitiveVertices
Definition MeshPack.h:74
PrimitiveLocations primitiveLocations
Definition MeshPack.h:75
PrimitivePoints primitivePoints
Definition MeshPack.h:73
virtual ~MeshResource()=default
Destructor Function.
void CreateBuffer(const std::string &name)
Create MeshResource Buffers.
Definition MeshPack.cpp:14
Mesh Resources Data.
Definition MeshPack.h:39
std::vector< size_t > meshlets
MeshletGroup for simplify.
void FromMeshopt(const meshopt_Meshlet &m, const meshopt_Bounds &bounds)
Destructor Function. @attemtion Why Destructor causes bug here.
Definition Vertex.cpp:85
Meshlet()=default
Constructor Function.
Meshlet Class. This class defines what Meshlet data.
Definition Vertex.h:58
when ProjectionType==Orthographic, use this.
Definition Camera.h:44
when ProjectionType==Perspective, use this.
Definition Camera.h:34
This struct defines the data used to create a texture2d. From render pass.
static constexpr char const * name
Define a named category tag type.
static constexpr char const * name
Define a custom domain tag type.
static constexpr char const * message
Define a registered string tag type.
String2()=default
Constructor Function.
std::string x
x component.
Definition Math.h:97
std::string y
y component.
Definition Math.h:102
virtual ~String2()=default
Destructor Function.
String2(const std::string &str0, const std::string &str1)
Constructor Function.
Definition Math.h:76
bool operator==(const String2 &other) const
equal operation.
Definition Math.h:88
double string
Definition Math.h:63
std::string texturePath
Definition Material.h:29
std::string textureType
Definition Material.h:28
This struct's data is defined from .material file.
Definition Material.h:27
Wrapper of 3D Transform.
Definition Transform.h:16
uint32_t y
y component.
Definition Math.h:56
uint32_t x
x component.
Definition Math.h:51
UInt2()=default
Constructor Function.
bool operator==(const UInt2 &other) const
equal operation.
Definition Math.h:42
virtual ~UInt2()=default
Destructor Function.
UInt2(const uint32_t &x, const uint32_t &y)
Constructor Function.
Definition Math.h:30
double unsigned int
Definition Math.h:17
void Init(VkInstance instance)
Init All Vulkan Function Pointer.
Vulkan Function Pointers Collection. It holds all function pointer which need get manually.
VulkanState(const VulkanState &)=delete
Copy Constructor Function.
VkSwapchainKHR m_SwapChain
VkCommandPool m_GraphicCommandPool
std::array< VkSemaphore, MaxFrameInFlight > m_ComputeQueueSemaphore
VmaAllocator m_VmaAllocator
Definition VulkanUtils.h:97
std::array< VkImage, MaxFrameInFlight > m_SwapChainImages
std::array< VkImageView, MaxFrameInFlight > m_SwapChainImageViews
std::array< VkSemaphore, MaxFrameInFlight > m_GraphicQueueSemaphore
std::array< VkFence, MaxFrameInFlight > m_ComputeFence
std::array< VkSampler, MaxFrameInFlight > m_SwapChainImageSamplers
uint32_t m_ComputeQueueFamily
std::array< VkCommandBuffer, MaxFrameInFlight > m_GraphicCommandBuffer
VulkanFunctions m_VkFunc
Definition VulkanUtils.h:98
GLFWwindow * m_Windows
Definition VulkanUtils.h:92
VkInstance m_Instance
Definition VulkanUtils.h:93
uint32_t m_GraphicQueueFamily
VulkanState()=default
Constructor Function.
std::array< VkSemaphore, MaxFrameInFlight > m_GraphicImageSemaphore
VkSurfaceKHR m_Surface
Definition VulkanUtils.h:94
std::array< VkCommandBuffer, MaxFrameInFlight > m_ComputeCommandBuffer
VkPhysicalDevice m_PhysicalDevice
Definition VulkanUtils.h:95
VkCommandPool m_ComputeCommandPool
std::array< VkFence, MaxFrameInFlight > m_GraphicFence
VulkanState & operator=(const VulkanState &)=delete
Copy Assignment Operation.
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74
virtual ~Node()
Destructor Function.
Definition KDTree.h:580
Node * m_Right
Pointer to right child.
Definition KDTree.h:68
Node * m_Left
Pointer to left child.
Definition KDTree.h:63
Node(const item &pt)
Constructor Function.
Definition KDTree.h:44
item m_Point
Array to store the coordinates.
Definition KDTree.h:58
size_t operator()(Spices::EdgePoint const &edgeP) const
Definition Vertex.h:255
size_t operator()(Spices::Edge const &edge) const
Definition Vertex.h:236
size_t operator()(Spices::HalfEdge const &edge) const
Definition Vertex.h:246
size_t operator()(Spices::String2 const &info) const noexcept
Definition Math.h:187
size_t operator()(Spices::UInt2 const &info) const noexcept
Definition Math.h:179
std::size_t operator()(const Spices::UUID &uuid) const noexcept
Definition UUID.h:62