TazGraph Project v0.1.0
Loading...
Searching...
No Matches
CellEntity.h
1#pragma once
2
3#include "GECS.h"
4#include <mutex>
5
6struct Cell {
7 std::mutex mtx;
8
9 std::vector<EntityID> emptyEntities;
10 std::vector<EntityID> nodes;
11 std::vector<EntityID> links;
12
13 glm::vec3 boundingBox_origin = glm::vec3(0); // Starting point (minimum corner) of the cell
14 glm::vec3 boundingBox_size = glm::vec3(0);
15 glm::vec3 boundingBox_center = glm::vec3(0);
16
17 Cell* parent = nullptr;
18 std::vector<Cell*> children;
19
20 template <typename T>
21 std::vector<T*>& getEntityList() {
22 if constexpr (std::is_same_v<T, NodeEntity>) {
23 return nodes;
24 }
25 else if constexpr (std::is_same_v<T, EmptyEntity>) {
26 return emptyEntities;
27 }
28 else if constexpr (std::is_same_v<T, LinkEntity>) {
29 return links;
30 }
31 else {
32 static_assert(sizeof(T) == 0, "Unsupported entity type.");
33 }
34 }
35};
36
37
38class CellEntity : public Entity {
39public:
40 Cell* ownerCell = nullptr;
41
42
43 CellEntity(Manager& mManager) : Entity(mManager) {
44
45 }
46
47 void setOwnerCell(Cell* cell) {
48 this->ownerCell = cell;
49 }
50
51
52 Cell* getOwnerCell() const { return ownerCell; }
53
54};
55
56class MultiCellEntity : public Entity {
57public:
58 std::vector<Cell*> ownerCells = {};
59
60 MultiCellEntity(Manager& mManager) : Entity(mManager) {
61
62 }
63
64 void setOwnerCells(std::vector<Cell*> cells) {
65 this->ownerCells = cells;
66 }
67
68 Cell* getOwnerCells() const { return ownerCells[0]; }
69
70};
Definition CellEntity.h:38
Definition GECS.h:224
Definition GECSManager.h:20
Definition CellEntity.h:56
Definition CellEntity.h:6