41class [[ToastNode, Hidden, Interface, Icon(
"Shape"), Color(
"Magenta")]] TOAST_API
VoxelPiece :
public Voxel {
54 void setVoxel(glm::vec3 pos,
int id);
57 void removeVoxel(glm::vec3 pos);
86 void carveBox(glm::vec3 min, glm::vec3 max);
89 void carveSphere(glm::vec3 center,
float radius);
92 void paintBox(glm::vec3 min, glm::vec3 max,
int id);
140 void setClipPlanes(std::vector<glm::vec4> planes);
147 void clearClipPlanes();
171 virtual auto kind() const noexcept ->
PieceKind {
176 virtual auto writeMode() const noexcept -> voxel::WriteMode {
181 virtual auto matchId() const noexcept -> uint8_t {
192 std::shared_ptr<const Grid> base;
193 std::unique_ptr<voxel::Volume> volume;
194 std::array<uint32_t, voxel::k_palette_size> histogram {};
197 using GridRef = std::shared_ptr<const Grid>;
227 return m_job.valid();
233 return m_grid_dirty || m_job.valid();
242 return m_input_revision;
248 return m_build_count;
252 auto clipPlanes() const noexcept -> const std::vector<glm::vec4>& {
253 return m_clip_planes;
272 void setMisaligned(
bool misaligned);
277 virtual auto pieceSize() -> glm::ivec3;
287 void markGridDirty() noexcept;
292 void onReflectedFieldChanged(std::string_view field_name)
override;
293 void onScriptsReloading()
override;
294 void onScriptsReloaded()
override;
295 void onScriptVarChanged(std::string_view path)
override;
296 void updateInspectorMessages()
override;
298 template<
typename Kernel>
299 void draw(std::string_view operation, Kernel&& kernel);
303 auto drawing() const noexcept -> voxel::
Volume*;
313 [[
Reflect, Name(
"Clip Planes"), Group(
"Clip")]]
319 auto drawGrid() -> GridRef;
322 void landGrid(GridRef fresh);
329 auto latestGrid() -> const voxel::
Volume*;
333 std::future<GridRef> m_job;
334 bool m_grid_dirty = true;
335 bool m_clip_dirty = true;
336 bool m_misaligned = false;
337 bool m_warned_outside_edit = false;
338 uint32_t m_input_revision = 1;
339 uint32_t m_build_count = 0;
Type-safe smart pointer for assets.
Definition core_types.hpp:149
Definition voxel_model.hpp:43
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Definition reflect.hpp:244
Definition voxel_piece.hpp:41
void requestGrid()
Definition voxel_piece.cpp:259
void addClipPlane(glm::vec4 plane)
Definition voxel_piece.cpp:325
auto collectGrid() -> bool
Definition voxel_piece.cpp:276
virtual void finishGrid(voxel::Volume &)
Definition voxel_piece.hpp:284
virtual auto pieceSize() -> glm::ivec3
Definition voxel_piece.cpp:69
void fillRoundBox(glm::vec3 min, glm::vec3 max, float radius, int id, voxel::WriteMode mode=voxel::WriteMode::replace, int match_id=0)
Definition voxel_piece.cpp:100
auto getSize() -> glm::vec3
Definition voxel_piece.cpp:65
auto gridRef() -> GridRef
Definition voxel_piece.cpp:244
void tile(const assets::Handle< assets::VoxelModel > &asset, int fit=0, glm::vec3 anchor=glm::vec3(0.0f), glm::vec3 offset=glm::vec3(0.0f), glm::vec3 mirror=glm::vec3(0.0f), voxel::WriteMode mode=voxel::WriteMode::replace, int match_id=0)
Definition voxel_piece.cpp:160
auto getClipPlanes() const -> std::vector< glm::vec4 >
Definition voxel_piece.cpp:315
std::vector< glm::vec4 > m_clip_planes
Definition voxel_piece.hpp:314
virtual auto sourcePaletteUid() const -> uint64_t
Definition voxel_piece.hpp:187
auto getShapeScript() const -> const assets::Handle< assets::Script > &
Definition voxel_piece.cpp:311
signals::Signal drawn
Sent after editShape drew the grid again.
Definition voxel_piece.hpp:166
auto getVoxel(glm::vec3 pos) -> int
Definition voxel_piece.cpp:74
void stamp(const assets::Handle< assets::VoxelModel > &asset, glm::vec3 pos, glm::quat rotation=glm::quat(1.0f, 0.0f, 0.0f, 0.0f), voxel::WriteMode mode=voxel::WriteMode::replace, int match_id=0)
Definition voxel_piece.cpp:140
virtual auto prepareGrid() -> std::unique_ptr< voxel::Volume >=0
auto gridBuilding() const noexcept -> bool
Definition voxel_piece.hpp:226
virtual auto resizable() const noexcept -> bool
Definition voxel_piece.hpp:264
auto readyGrid() -> GridRef
Definition voxel_piece.cpp:290
auto getShapeBounds() -> std::vector< glm::vec3 >
Definition voxel_piece.cpp:337
void fillEllipsoid(glm::vec3 min, glm::vec3 max, int id, voxel::WriteMode mode=voxel::WriteMode::replace, int match_id=0)
Definition voxel_piece.cpp:110
void setShapeScript(assets::Handle< assets::Script > script)
Definition voxel_piece.cpp:369
auto inputRevision() const noexcept -> uint32_t
Definition voxel_piece.hpp:241
void markLandingDirty() noexcept
Definition voxel_piece.hpp:290
auto gridStale() const noexcept -> bool
Definition voxel_piece.hpp:232
auto getShape() -> Box< Node >
Definition voxel_piece.cpp:345
assets::Handle< assets::Script > m_shape_script
Definition voxel_piece.hpp:310
auto grid() -> const voxel::Volume *
Definition voxel_piece.cpp:254
auto isMisaligned() const noexcept -> bool
Definition voxel_piece.hpp:162
auto buildCount() const noexcept -> uint32_t
Definition voxel_piece.hpp:247
auto nominalSize() -> glm::ivec3
Definition voxel_piece.hpp:258
void redraw()
Definition voxel_piece.cpp:307
Definition voxel_volume.hpp:21
Definition voxel_piece.hpp:191
Concrete asset types for the Toast engine.
Common base of every voxel node.
Functions that allow the editing of Voxel Volumes.
WriteMode
Which voxels we should override.
Definition voxel_edit.hpp:26
@ replace
Everything.
Definition voxel_edit.hpp:27
PieceKind
Definition voxel_piece.hpp:26
@ carve
Empties every voxel it has.
Definition voxel_piece.hpp:28
@ fill
Adds its voxels with its write mode.
Definition voxel_piece.hpp:27
@ paint
Recolors voxels that are already solid.
Definition voxel_piece.hpp:29