Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
voxel_scene_patcher.hpp
Go to the documentation of this file.
1
4
5
#pragma once
6
7
#include "
voxel_change_history.hpp
"
8
9
#include <cstdint>
10
#include <glm/glm.hpp>
11
#include <optional>
12
#include <span>
13
#include <
toast/voxel/brick_pool.hpp
>
14
#include <
toast/voxel/gpu_layout.hpp
>
15
#include <vector>
16
17
namespace
renderer {
18
20
class
VoxelScenePatcher
{
21
public
:
22
struct
Patched
{
23
voxel::gpu::ScenePatch
patch;
25
std::vector<uint64_t>
record_rids
;
26
std::vector<glm::uvec3> record_dims;
27
};
28
30
void
adopt
(
const
voxel::gpu::PackedScene
& scene, uint32_t pool_slots, std::vector<uint64_t> node_rids);
31
33
[[nodiscard]]
34
auto
tryPatch
(
35
const
voxel::BrickPool
& pool, std::span<const voxel::gpu::SceneVolume> volumes, std::span<const uint64_t> node_rids,
36
std::span<const VolumeDelta> deltas
37
) -> std::optional<Patched>;
38
39
void
reset();
40
41
[[nodiscard]]
42
auto
valid() const noexcept ->
bool
{
43
return
m_valid;
44
}
45
46
[[nodiscard]]
47
auto
scene() const noexcept -> const voxel::gpu::PackedScene& {
48
return
m_scene;
49
}
50
51
[[nodiscard]]
52
auto
poolSlots() const noexcept -> uint32_t {
53
return
m_pool_slots;
54
}
55
56
private
:
57
[[nodiscard]]
58
auto
paletteMatches(
const
voxel::gpu::VolumeRecord& record,
const
voxel::Palette& palette)
const
-> bool;
59
61
auto
findOrAppendPalette(
const
voxel::Palette& palette) -> uint32_t;
62
63
voxel::gpu::PackedScene m_scene;
64
uint32_t m_pool_slots = 0;
65
std::vector<uint64_t> m_node_rids;
67
uint64_t m_dead_grid_words = 0;
68
bool
m_valid =
false
;
69
};
70
71
}
brick_pool.hpp
renderer::VoxelScenePatcher
Records stay in place so a removed volume leaves a dead record and a new one is appended.
Definition
voxel_scene_patcher.hpp:20
renderer::VoxelScenePatcher::adopt
void adopt(const voxel::gpu::PackedScene &scene, uint32_t pool_slots, std::vector< uint64_t > node_rids)
A full pack is what the GPU will hold so later patches build on it.
Definition
voxel_scene_patcher.cpp:28
renderer::VoxelScenePatcher::tryPatch
auto tryPatch(const voxel::BrickPool &pool, std::span< const voxel::gpu::SceneVolume > volumes, std::span< const uint64_t > node_rids, std::span< const VolumeDelta > deltas) -> std::optional< Patched >
Definition
voxel_scene_patcher.cpp:55
voxel::BrickPool
Definition
brick_pool.hpp:26
gpu_layout.hpp
renderer::VoxelScenePatcher::Patched
Definition
voxel_scene_patcher.hpp:22
renderer::VoxelScenePatcher::Patched::record_rids
std::vector< uint64_t > record_rids
Per record and 0 for a dead one.
Definition
voxel_scene_patcher.hpp:25
voxel::gpu::PackedScene
Definition
gpu_layout.hpp:76
voxel::gpu::ScenePatch
Definition
gpu_layout.hpp:116
voxel_change_history.hpp
engine
src
toast
renderer
voxel_scene_patcher.hpp
Generated by
1.17.0