28#include <unordered_map>
48 glm::vec4 average_color {0.0f};
62 [[
Reflect, Button(
"Bake"), EditorAction(
"voxel_editor.bake")]]
74 auto getPieceAt(glm::vec3 pos) ->
Box<Node>;
79 return static_cast<int>(m_layout.size());
87 auto pickPiece(glm::vec3 origin, glm::vec3 direction) ->
VoxelPiece*;
97 void keepGrids(
bool keep)
noexcept { m_keep_grids = keep; }
109 auto composePieces(std::span<VoxelPiece* const> only) -> std::optional<Composed>;
112 void buildShape()
override;
113 auto shapeKey() -> uint64_t
override;
114 auto buildsAsync() ->
bool override;
115 void tickAsyncBuild()
override;
118 void drawDebug()
override;
126 glm::mat4 to_root {1.0f};
131 VoxelPiece* piece =
nullptr;
132 VoxelPiece::GridRef grid;
133 voxel::LatticePlacement placement;
137 uint8_t match_id = 0;
141 struct ComposeOutput;
143 void collect(Node& node,
const glm::mat4& to_root, std::vector<Collected>& out);
146 VoxelBucket* bucket =
nullptr;
151 void collectBuckets(Node& node,
const glm::mat4& to_root, std::vector<BucketFill>& out);
158 auto land(
const std::vector<Collected>& pieces,
bool wait) -> std::vector<Landing>;
161 static auto apply(voxel::Volume& target,
const Landing& landing, glm::ivec3 origin) -> voxel::EditResult;
165 static auto compose(
const ComposeInput& input) -> std::shared_ptr<ComposeOutput>;
168 auto keyOf(
const std::vector<Collected>& pieces) -> uint64_t;
172 auto layoutOf(
const std::vector<Landing>& landings) -> std::vector<PieceLayout>;
175 void launchCompose(
const std::vector<Collected>& pieces);
178 void applyComposed(ComposeOutput& output);
181 auto averageColor(
const Landing& landing) -> glm::vec3;
187 auto toolPiece() -> VoxelPiece*;
189 std::unique_ptr<voxel::Volume> m_highlight;
192 std::vector<PieceLayout> m_layout;
193 std::vector<PieceLayout> m_pending_layout;
194 bool m_keep_grids =
false;
196 std::future<std::shared_ptr<ComposeOutput>> m_compose_job;
197 std::shared_ptr<ComposeOutput> m_last_compose;
198 bool m_compose_wanted =
false;
199 bool m_pending_projections =
false;
203 uint64_t target_uid = 0;
204 uint32_t source_revision = 0;
205 uint32_t target_revision = 0;
208 std::unordered_map<uint64_t, CachedRemap> m_remaps;
213TOAST_API
auto insideProceduralVoxel(
Node& node) -> bool;
223TOAST_API
auto parentToShape(
Node& node) -> glm::mat4;
227TOAST_API
auto piecePlacement(
VoxelPiece& piece) -> voxel::LatticePlacement;
231TOAST_API
auto pieceBounds(
VoxelPiece& piece) -> voxel::EditBounds;
237TOAST_API
void placePiece(
VoxelPiece& piece,
const voxel::LatticeOrientation& orientation, glm::ivec3 min, glm::ivec3 max);
241TOAST_API
auto planeToShape(glm::vec4 plane,
const voxel::LatticePlacement& placement)
noexcept -> glm::vec4;
245TOAST_API
auto planeToPiece(glm::vec4 plane,
const voxel::LatticePlacement& placement)
noexcept -> glm::vec4;
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Definition procedural_voxel.hpp:41
auto layout() const noexcept -> const std::vector< PieceLayout > &
Definition procedural_voxel.hpp:53
void bakeVoxel()
Definition procedural_voxel.hpp:63
auto getPieceCount() const noexcept -> int
Definition procedural_voxel.hpp:78
void keepGrids(bool keep) noexcept
Definition procedural_voxel.hpp:97
Definition reflect.hpp:244
Definition voxel_piece.hpp:41
Definition voxel_volume.hpp:21
A box of voxels inside a ProceduralVoxel.
std::array< uint8_t, k_palette_size > PaletteRemapTable
Index 0 always maps to 0.
Definition stamp.hpp:138
Definition workspace_events.hpp:210
Definition procedural_voxel.hpp:99
glm::ivec3 origin
Shape voxel of the volume's first voxel.
Definition procedural_voxel.hpp:101
Definition procedural_voxel.hpp:43
voxel::EditBounds bounds
Where the grid lands, in shape voxels.
Definition procedural_voxel.hpp:47
Definition voxel_edit.hpp:49
A flood fill inside a ProceduralVoxel.
Functions that allow the editing of Voxel Volumes.
WriteMode
Which voxels we should override.
Definition voxel_edit.hpp:26
Keeps pieces of a ProceduralVoxel together.
Frontend for a Voxel node.
Base of everything a ProceduralVoxel builds itself from.
PieceKind
Definition voxel_piece.hpp:26
@ fill
Adds its voxels with its write mode.
Definition voxel_piece.hpp:27