Toast Engine
Loading...
Searching...
No Matches
voxel_scene_patcher.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
8
9#include <cstdint>
10#include <glm/glm.hpp>
11#include <optional>
12#include <span>
15#include <vector>
16
17namespace renderer {
18
21public:
22 struct Patched {
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
56private:
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}
Records stay in place so a removed volume leaves a dead record and a new one is appended.
Definition voxel_scene_patcher.hpp:20
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
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
Definition brick_pool.hpp:26
Definition voxel_scene_patcher.hpp:22
std::vector< uint64_t > record_rids
Per record and 0 for a dead one.
Definition voxel_scene_patcher.hpp:25
Definition gpu_layout.hpp:76
Definition gpu_layout.hpp:116