summaryrefslogtreecommitdiff
path: root/src/components.hpp
blob: 7d298ec59932e218d45c59804e78df3a0035cd77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef PKE_COMPONENTS_HPP
#define PKE_COMPONENTS_HPP

#include "dynamic-array.hpp"
#include "macros.hpp"
#include "physics.hpp"
#include "plugin-types.hpp"

#include <BulletDynamics/Dynamics/btRigidBody.h>
#include <LinearMath/btDefaultMotionState.h>
#include <vulkan/vulkan_core.h>

const uint64_t ECS_UNSET_VAL = 0xFFFFFFFFFFFFFFFF;
const uint32_t ECS_UNSET_VAL_32 = 0xFFFFFFFF;

struct EntityHandle : public PkeHandle { };
struct GrBindsHandle : public PkeHandle { };
struct InstanceHandle : public PkeHandle { };

constexpr EntityHandle EntityHandle_MAX = EntityHandle{};
constexpr GrBindsHandle GrBindsHandle_MAX = GrBindsHandle{};
constexpr InstanceHandle InstanceHandle_MAX = InstanceHandle{};

struct Entity_Base {
	EntityHandle handle = EntityHandle_MAX;
	EntityHandle parentHandle = EntityHandle_MAX;
	bool isMarkedForRemoval = false;
};

struct BufferBindingDetails {
	VkBuffer buffer = VK_NULL_HANDLE;
	uint32_t firstBinding = 0;
	uint32_t bindingCount = 0;
	VkDeviceSize offsets[1] = {0};
};
struct CompGrBinds {
	EntityHandle entHandle = EntityHandle_MAX;
	GrBindsHandle grBindsHandle = GrBindsHandle_MAX;
	VkPipelineLayout vkPipelineLayout = VK_NULL_HANDLE;
	VkPipeline graphicsPipeline = VK_NULL_HANDLE;
	VkDescriptorSet *vkDescriptorSets = nullptr;
	VkBuffer vertexBuffer = VK_NULL_HANDLE;
	uint32_t vertexFirstBinding = 0;
	uint32_t vertexBindingCount = 0;
	VkDeviceSize vertexOffsets = 0;
	VkBuffer normalsBuffer = VK_NULL_HANDLE;
	uint32_t normalsFirstBinding = 0;
	uint32_t normalsBindingCount = 0;
	VkDeviceSize normalsOffsets = 0;
	VkBuffer uvBuffer = VK_NULL_HANDLE;
	uint32_t uvFirstBinding = 0;
	uint32_t uvBindingCount = 0;
	VkDeviceSize uvOffsets = 0;
	VkBuffer indexBuffer = VK_NULL_HANDLE;
	uint32_t indexBindingCount = 0;
	VkDeviceSize indexOffsets = 0;
	VkDeviceSize indexCount = 0;
	BufferBindingDetails physVertBD;
	BufferBindingDetails physNormBD;
	BufferBindingDetails physUvBD;
	BufferBindingDetails physIndxBD;
	VkBuffer instanceBuffer = VK_NULL_HANDLE;
	uint32_t instanceFirstBinding = 0;
	uint32_t instanceBindingCount = 0;
	uint32_t instanceCounter = 0;
	uint32_t instanceBufferMaxCount = 0;
	VkDeviceSize instanceOffsets = 0;
	PkeCallback collisionCallback{};
};

struct InstPos {
	btTransform posRot;
	btVector3 scale;
	btScalar mass;
};
struct InstBt {
	btDefaultMotionState *motionState = nullptr;
	btRigidBody *rigidBody = nullptr;
};
struct CompInstance {
	EntityHandle entHandle = EntityHandle_MAX;
	GrBindsHandle grBindsHandle = GrBindsHandle_MAX;
	InstanceHandle instanceHandle = InstanceHandle_MAX;
	uint32_t index = ECS_UNSET_VAL_32;
	PhysicsCollision physicsLayer = PhysicsCollision{1};
	PhysicsCollision physicsMask = PhysicsCollision{1};
	InstBt bt;
	PkeCallback collisionCallback{};
	bool isNeedingUpdated = false;
};

#endif /* PKE_COMPONENTS_HPP */