34constexpr auto canWrite(uint8_t current, WriteMode mode, uint8_t match_id)
noexcept ->
bool {
36 case WriteMode::replace:
return true;
37 case WriteMode::empty_only:
return current == k_empty_palette_index;
38 case WriteMode::solid_only:
return current != k_empty_palette_index;
39 case WriteMode::match:
return current == match_id;
45constexpr auto canAdd(uint8_t
id,
WriteMode mode, uint8_t match_id)
noexcept ->
bool {
46 return id != k_empty_palette_index && canWrite(k_empty_palette_index, mode, match_id);
54 auto empty()
const noexcept ->
bool {
55 return glm::any(glm::lessThan(max, min));
62 bool pool_exhausted =
false;
65 changed += other.changed;
66 pool_exhausted = pool_exhausted || other.pool_exhausted;
72 uint8_t
id = k_empty_palette_index;
74 uint8_t match_id = k_empty_palette_index;
79 std::vector<uint8_t> ids;
86TOAST_API
auto boxBounds(glm::ivec3 a, glm::ivec3 b)
noexcept ->
EditBounds;
89TOAST_API
auto sphereBounds(glm::vec3 center,
float radius)
noexcept ->
EditBounds;
92TOAST_API
auto segmentBounds(glm::vec3 a, glm::vec3 b,
float radius)
noexcept ->
EditBounds;
101TOAST_API
auto occupiedBounds(
const Volume& volume) -> std::optional<EditBounds>;
117TOAST_API
auto replaceId(
Volume& volume, uint8_t from, uint8_t to) ->
EditResult;
125TOAST_API
auto slice(
Volume& volume, glm::vec3 point, glm::vec3 normal,
int side) ->
EditResult;
131TOAST_API
auto collectFace(
const Volume& volume, glm::ivec3 start, glm::ivec3 normal,
size_t limit =
size_t {1} << 20)
132 -> std::vector<glm::ivec3>;
137TOAST_API
auto extrudeFace(Volume& volume, std::span<const glm::ivec3> face, glm::ivec3 normal,
int distance) -> EditResult;
140TOAST_API
auto copyRegion(
const Volume& volume, glm::ivec3 a, glm::ivec3 b) -> Region;
142TOAST_API
auto pasteRegion(Volume& volume,
const Region& region, glm::ivec3 at, WriteMode mode, uint8_t match_id) -> EditResult;
144TOAST_API
auto stampVolume(
145 Volume& target,
const Volume& piece,
const LatticePlacement& placement,
const PaletteRemapTable& remap, WriteMode mode,
153TOAST_API
auto carveVolume(Volume& target,
const Volume& piece,
const LatticePlacement& placement) -> EditResult;
158TOAST_API
auto fillRoundBox(Volume& volume, glm::ivec3 a, glm::ivec3 b,
float radius,
const WriteBrush& brush) -> EditResult;
161TOAST_API
auto fillEllipsoid(Volume& volume, glm::ivec3 a, glm::ivec3 b,
const WriteBrush& brush) -> EditResult;
169TOAST_API
auto clipByPlanes(Volume& volume, std::span<const glm::vec4> planes) -> EditResult;
173TOAST_API
auto complementPlane(glm::vec4 plane)
noexcept -> glm::vec4;
177enum class TileFit : uint8_t {
183enum class TileAnchor : uint8_t {
190 TileFit fit = TileFit::crop;
191 std::array<TileAnchor, 3> anchor {TileAnchor::min, TileAnchor::min, TileAnchor::min};
200TOAST_API
auto tileVolume(
201 Volume& target,
const Volume& pattern, glm::ivec3 a, glm::ivec3 b,
const TileOptions& options,
const PaletteRemapTable& remap,
202 WriteMode mode = WriteMode::replace, uint8_t match_id = k_empty_palette_index
206TOAST_API
auto floodFill(Volume& volume, glm::ivec3 seed, uint8_t
id) -> EditResult;
220TOAST_API
auto raycast(
const Volume& volume, glm::vec3 origin, glm::vec3 direction,
float max_t) -> std::optional<VolumeHit>;
224TOAST_API
auto idHistogram(
const Volume& volume) -> std::array<uint32_t, k_palette_size>;
227TOAST_API
auto snapOrientation(
const glm::mat3& rotation)
noexcept -> LatticeOrientation;
230TOAST_API
auto dominantAxis(glm::vec3 normal)
noexcept -> glm::ivec3;
Definition voxel_volume.hpp:21
Definition voxel_edit.hpp:49
Definition voxel_edit.hpp:59
Definition voxel_edit.hpp:77
Definition voxel_edit.hpp:189
glm::ivec3 offset
Shifts the tiles by this many voxels.
Definition voxel_edit.hpp:192
glm::bvec3 mirror
Flips every other tile on that axis.
Definition voxel_edit.hpp:193
Definition voxel_edit.hpp:208
glm::ivec3 normal
The face it came through, zero when it started inside.
Definition voxel_edit.hpp:210
glm::ivec3 voxel
The solid voxel it stopped in.
Definition voxel_edit.hpp:209
Definition voxel_edit.hpp:71
WriteMode
Which voxels we should override.
Definition voxel_edit.hpp:26
@ replace
Everything.
Definition voxel_edit.hpp:27
@ empty_only
Only empty space.
Definition voxel_edit.hpp:28
@ solid_only
Only non-empty space.
Definition voxel_edit.hpp:29
@ match
Only voxels with the match id.
Definition voxel_edit.hpp:30