summaryrefslogtreecommitdiff
path: root/src/entities.hpp
blob: 8429d7f370aa28f6562d1880a309de9c9de6ca4f (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
#ifndef PKE_ENTITIES_HPP
#define PKE_ENTITIES_HPP

#include "vendor/cgltf-include.hpp"
#include "vendor/stb_image_include.hpp"
#include "ecs.hpp"
#include "components.hpp"
#include "asset-manager.hpp"
#include "memory.hpp"
#include "window.hpp"

#include <BulletCollision/CollisionShapes/btCollisionShape.h>
#include <vulkan/vulkan_core.h>

struct EntityType {
	const char *modelsDir = nullptr;
	const char *modelFile = nullptr;
	const char *entityTypeCode = nullptr;
	EntityHandle entityHandle;
	GrBindsHandle grBindsHandle = GrBindsHandle_MAX;
	VkDeviceMemory deviceMemoryVert = VK_NULL_HANDLE;
	VkDeviceMemory deviceMemoryInst = VK_NULL_HANDLE;
	VkDeviceMemory deviceMemoryPhysVert = VK_NULL_HANDLE;
	VkDeviceMemory deviceMemoryTexture = VK_NULL_HANDLE;
	VkImage textureImage = VK_NULL_HANDLE;
	VkImageView textureImageView = VK_NULL_HANDLE;
	VkDescriptorPool vkDescriptorPool = VK_NULL_HANDLE;
	uint32_t startingInstanceCount = 1024;
	struct Importer_GLTF {
		int16_t AccessorIndexVertex = -1;
		int16_t AccessorIndexNormal = -1;
		int16_t AccessorIndexUV = -1;
		int16_t AccessorIndexIndex = -1;
	} Importer_GLTF;
	struct {
		btCollisionShape *shape = nullptr;
		btScalar startingMass = 1.f;
		PhysicsCollision startingCollisionLayer = PhysicsCollision{1};
		PhysicsCollision startingCollisionMask = PhysicsCollision{1};
	} bt;
};
extern DynArray<EntityType> GlobalEntityTypes;

void EntityType_Init();
int64_t EntityType_FindByTypeCode(const char *typeCode);
int64_t EntityType_FindByEntityHandle(EntityHandle handle);
void EntityType_Load(EntityType &et);
void EntityType_Tick_Late(double delta);
void EntityType_RolloverInstances(EntityType &et, CompGrBinds &grBinds);
void EntityType_Teardown();

#endif /* PKE_ENTITIES_HPP */