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 against cull bounds if set, then submits an indexed draw call.
36
virtual
void
Update
(
float
deltaTime)
override
;
37
38
void
SetVertexBuffer(
RefPtr<RenderEngine::BufferBase>
& buffer);
39
40
void
SetIndexBuffer(
RefPtr<RenderEngine::BufferBase>
& buffer);
41
42
/// Creates a new constant buffer from bufferData and appends it to the draw's buffer list.
43
void
AddConstantBuffer(
RenderEngine::TransformBuffer
& bufferData);
44
45
void
AddConstantBuffer(
RefPtr<RenderEngine::BufferBase>
& buffer);
46
47
// World-space bounds used for CPU frustum culling of this mesh.
48
void
SetCullBoundsWorld(
const
Math::AABB
& bounds);
49
// Local-space bounds, transformed by the owner each Update.
50
void
SetCullBoundsLocal(
const
Math::AABB
& bounds);
51
52
private
:
53
RefPtr<RenderEngine::BufferBase>
VertexBuffer{};
54
RefPtr<RenderEngine::BufferBase> IndexBuffer{};
55
List<RefPtr<RenderEngine::BufferBase>> ConstantBuffers{};
56
57
uint32_t VertexCount;
58
uint32_t IndexCount;
59
60
Math::AABB m_cullBounds{};
61
bool
m_hasCullBounds =
false
;
62
Math::AABB m_localBounds{};
63
bool
m_hasLocalBounds =
false
;
64
65
};
66
}
67
68
#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:62
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:83
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