3#include "Systems/ComponentSystem.h"
5#include "../Components/OctComponent.h"
6#include "../Renderers/OctAtlas.h"
8#include "Rendering/Common.h"
10#include "Foundation/Collections/Pool.h"
14#include <unordered_map>
22 class CameraComponent;
23 class TransformComponent;
32 typedef uint64_t BaseBlockKey;
34 inline BaseBlockKey createBaseBlockKey(
int x,
int y,
int z)
36 return uint64_t(uint16_t(z)) << 32 | uint64_t(uint16_t(y)) << 16 | uint64_t(uint16_t(x));
53 glm::u16vec3 extentMin;
54 glm::u16vec3 extentMax;
75 std::unordered_map<BaseBlockKey, OctBaseBlock*> baseBlocks;
78 std::unordered_map<uint64_t, OctRegionData*> knownRegions;
81 std::vector<TileResponse*> tileResponses;
82 std::vector<TileResponse*> tileResponsesStash;
84 std::vector<NodeBlock> nodes;
88 std::vector<uint32_t> stack;
90 std::vector<uint32_t> front;
91 std::vector<uint32_t> frontTmp;
93 uint32_t currentTimestamp = 0;
95 float tolerance = 0.1f;
96 unsigned maxFrontSize = 1;
100 size_t layoutHash = 0;
102 bool gpuCacheWipe =
true;
107 OctSource source = OctSource::Value;
109 unsigned instanceCount = 0;
117 static const unsigned maxResponses = 5;
118 static const unsigned skirtSize = 1;
127 static glm::mat4 LocalFromIndexSpaceTransform(
const OctComponent& octComp,
const OctData& octData);
128 static glm::mat4 IndexSpaceFromLocalTransform(
const OctComponent& octComp,
const OctData& octData);
Context * context
Pointer to the Context instance the system lives in.
void update()
Updates the system state to that of the current frame.
Component system with parallel data per component stored in a pool similar to how the components them...
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Base allocator implementation.
uint16_t VariableKey
Used to lookup material properties.
Contains all Cogs related functionality.
ComponentIndex SizeType
Type used to track the size of pools.
Pool used to store elements of ElementType.
Handle to a Component instance.
Contains data describing a Camera instance and its derived data structured such as matrix data and vi...
Representing a block or node in the oct-tree.
uint32_t timestamp
Timestamp of the most recent adding of a region in the tree below.
glm::u16vec4 ix4
Oct-tree index, base level is baseblock ix3 minus alignMinToZeroShift.
Represent the blocks at the oct-tree base level. Independent on current the particular oct-tree.
std::set< RegionKey > regionKeys
Regions intersecting this block.
glm::i16vec3 ix3
Index without block shift.
uint32_t timestamp
Timestamp last time a region was added to block.
glm::i16vec3 alignMinToZeroShift
Shift value for baseBlock ix3 to get them non-negative.
std::vector< uint64_t > baseBlocks
Base blocks that intersects with this region.
glm::vec3 min
Object space min corner of region bounding box.
glm::vec3 max
Object space max corner of region bounding box.
void initialize(Context *context) override
Initialize the system.
ComponentModel::ComponentHandle createComponent() override