1#include "OctComponent.h"
3#include "../Systems/OctSystem.h"
7void Cogs::Core::Volumetric::OctComponent::registerType()
11 Field(
Name(
"valueMax"), &OctComponent::valueMax),
12 Field(
Name(
"turbidity"), &OctComponent::turbidity),
13 Field(
Name(
"ageScale"), &OctComponent::ageScale),
15 Field(
Name(
"drawDebug"), &OctComponent::drawDebug),
18 Field(
Name(
"blockExtent"), &OctComponent::blockExtent),
19 Field(
Name(
"tileSize"), &OctComponent::tileSize),
20 Field(
Name(
"gpuCacheSize"), &OctComponent::gpuCacheSize),
21 Field(
Name(
"transferTexture"), &OctComponent::transferTexture),
25 Method(
Name(
"initTileResponse"), &OctComponent::initTileResponse),
26 Method(
Name(
"submitTileResponse"), &OctComponent::submitTileResponse),
29 Reflection::TypeDatabase::createType<OctComponent>()
37 CpuInstrumentationScope(SCOPE_VOLUMETRIC,
"OctComponent::initTileResponse");
38 auto & octData = system->getData(
this);
39 if (octData.tileResponsesStash.empty())
return nullptr;
41 auto res = std::move(octData.tileResponsesStash.back());
42 octData.tileResponsesStash.pop_back();
44 auto i = int16_t(req->tileKey & 0xffffu);
45 auto j = int16_t((req->tileKey >> 16u) & 0xffffu);
46 auto k = int16_t((req->tileKey >> 32u) & 0xffffu);
47 auto w = int16_t((req->tileKey >> 48u) & 0xffffu);
56 glm::ivec3 lll(i, j, k);
57 glm::ivec3 uuu = lll + glm::ivec3(1u << w);
60 res->regionKeys.clear();
61 for (
int z = lll.z; z < uuu.z; z++) {
62 for (
int y = lll.y; y < uuu.y; y++) {
63 for (
int x = lll.x; x < uuu.x; x++) {
64 const auto baseBlockKey = createBaseBlockKey(x, y, z);
65 auto it = octData.baseBlocks.find(baseBlockKey);
66 if (it != octData.baseBlocks.end()) {
67 res->regionKeys.insert(it->second->regionKeys.begin(), it->second->regionKeys.end());
73 const auto skirtExpand = (1u << w)*
float(Volumetric::OctSystem::skirtSize) / float(tileSize - Volumetric::OctSystem::skirtSize);
75 res->tileKey = req->tileKey;
76 res->layoutHash = octData.layoutHash;
77 res->timestamp = octData.currentTimestamp;
78 res->min = blockExtent*(glm::vec3(lll) - glm::vec3(skirtExpand)) + blockShift;
79 res->max = blockExtent*(glm::vec3(uuu) + glm::vec3(skirtExpand)) + blockShift;
80 res->N = glm::ivec3(tileSize);
85void Cogs::Core::Volumetric::OctComponent::submitTileResponse(TileResponse* res,
bool success)
88 auto & octData = system->getData(
this);
90 octData.tileResponses.push_back(std::move(res));
93 octData.tileResponsesStash.push_back(std::move(res));
Base class for Component instances.
Field definition describing a single data member of a data structure.
Simple method definition.
Contains reflection support.
float tolerance
Requested refinement tolerance, may be somewhat ignored when atlas size is insufficient.
glm::vec3 blockShift
Object space grid origin, tweak if block boundaries happen at unfortunate places.
bool forceWipe
Discard all processed data, but regions persist.
Represents an unique name.