SleakEngine
0.1.0
C++23 multi-backend game engine
Toggle main menu visibility
Loading...
Searching...
No Matches
MeshComponent.hpp
Go to the documentation of this file.
1
#ifndef _MESHCOMPONENT_H_
2
#define _MESHCOMPONENT_H_
3
4
#include <
ECS/Component.hpp
>
5
#include <
Utility/Container/List.hpp
>
6
#include <
Math/AABB.hpp
>
7
#include <
Memory/ObjectPtr.hpp
>
8
#include <
Memory/RefPtr.hpp
>
9
10
namespace
Sleak
{
11
class
MeshData
;
12
namespace
RenderEngine
{
13
class
TransformBuffer
;
14
class
BufferBase
;
15
}
// namespace RenderEngine
16
17
/// Untyped payload blob, currently unused by any buffer path.
18
struct
VoidData
{
19
uint16_t
size
;
20
void
*
data
;
21
};
22
23
/// Holds the GPU vertex/index/constant buffers for a renderable mesh and
24
/// submits a draw call each Update, subject to frustum culling.
25
/// @ingroup scene
26
class
ENGINE_API
MeshComponent
:
public
Component
{
27
public
:
28
MeshComponent
(
GameObject
*
object
) :
Component
(object) {}
29
/// Uploads data's vertex/index arrays to new GPU buffers.
30
MeshComponent
(
GameObject
*,
MeshData
data);
31
32
/// Validates that vertex and index buffers were created successfully.
33
virtual
bool
Initialize()
override
;
34
35
/// Culls, then submits sibling transform and material state and the
36
/// draw.
37
virtual
void
Update
(
float
deltaTime)
override
;
38
39
void
SetVertexBuffer(
RefPtr<RenderEngine::BufferBase>
& buffer);
40
41
void
SetIndexBuffer(
RefPtr<RenderEngine::BufferBase>
& buffer);
42
43
/// Creates a new constant buffer from bufferData and appends it to the draw's buffer list.
44
void
AddConstantBuffer(
RenderEngine::TransformBuffer
& bufferData);
45
46
void
AddConstantBuffer(
RefPtr<RenderEngine::BufferBase>
& buffer);
47
48
// World-space bounds used for CPU frustum culling of this mesh.
49
void
SetCullBoundsWorld(
const
Math::AABB
& bounds);
50
// Local-space bounds, transformed by the owner each Update.
51
void
SetCullBoundsLocal(
const
Math::AABB
& bounds);
52
53
private
:
54
RefPtr<RenderEngine::BufferBase>
VertexBuffer{};
55
RefPtr<RenderEngine::BufferBase> IndexBuffer{};
56
List<RefPtr<RenderEngine::BufferBase>> ConstantBuffers{};
57
58
uint32_t VertexCount;
59
uint32_t IndexCount;
60
61
Math::AABB m_cullBounds{};
62
bool
m_hasCullBounds =
false
;
63
Math::AABB m_localBounds{};
64
bool
m_hasLocalBounds =
false
;
65
66
};
67
}
68
69
#endif
AABB.hpp
Component.hpp
List.hpp
ObjectPtr.hpp
RefPtr.hpp
Sleak::Component::GameObject
friend class GameObject
Definition
Component.hpp:88
Sleak::Component::Component
Component(GameObject *object)
Definition
Component.hpp:61
Sleak::GameObject
Definition
GameObject.hpp:65
Sleak::MeshComponent
Definition
MeshComponent.hpp:26
Sleak::MeshComponent::MeshComponent
MeshComponent(GameObject *object)
Definition
MeshComponent.hpp:28
Sleak::RefPtr
Definition
RefPtr.hpp:62
Sleak::RenderEngine::BufferBase
Backend-agnostic GPU buffer: vertex, index, constant, or resource view target.
Definition
BufferBase.hpp:16
Sleak::EventType::Update
@ Update
Definition
Event.hpp:26
Sleak::RenderEngine
Backend-facing rendering layer shared by the four graphics backends.
Definition
Application.hpp:60
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
Sleak::Math::AABB
Definition
AABB.hpp:11
Sleak::MeshData
Definition
MeshData.hpp:103
Sleak::RenderEngine::TransformBuffer
Per-draw world-view-projection and world matrices.
Definition
ConstantBuffer.hpp:84
Sleak::VoidData
Untyped payload blob, currently unused by any buffer path.
Definition
MeshComponent.hpp:18
Sleak::VoidData::size
uint16_t size
Definition
MeshComponent.hpp:19
Sleak::VoidData::data
void * data
Definition
MeshComponent.hpp:20
include
public
ECS
Components
MeshComponent.hpp
Generated on
for SleakEngine by
1.18.0