MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
SDFNode.cpp
Go to the documentation of this file.
1#include "SDFNode.hpp"
2
4
6
8
11 const glm::vec3& bounds_min,
12 const glm::vec3& bounds_max,
13 uint32_t res_x,
14 uint32_t res_y,
15 uint32_t res_z,
16 float iso_level)
17 : MeshWriterNode(static_cast<size_t>(res_x * res_y * res_z) * 3)
18 , m_field(std::move(field))
19 , m_bounds_min(bounds_min)
20 , m_bounds_max(bounds_max)
21 , m_res_x(std::max(res_x, 1U))
22 , m_res_y(std::max(res_y, 1U))
23 , m_res_z(std::max(res_z, 1U))
24 , m_iso_level(iso_level)
25{
26 rebuild();
27}
28
30{
31 m_field = std::move(field);
32 m_dirty = true;
33}
34
35void SDFNode::set_bounds(const glm::vec3& bounds_min, const glm::vec3& bounds_max)
36{
37 m_bounds_min = bounds_min;
38 m_bounds_max = bounds_max;
39 m_dirty = true;
40}
41
42void SDFNode::set_resolution(uint32_t res_x, uint32_t res_y, uint32_t res_z)
43{
44 m_res_x = std::max(res_x, 1U);
45 m_res_y = std::max(res_y, 1U);
46 m_res_z = std::max(res_z, 1U);
47 m_dirty = true;
48}
49
50void SDFNode::set_iso_level(float iso_level)
51{
52 m_iso_level = iso_level;
53 m_dirty = true;
54}
55
57{
58 if (!m_dirty)
59 return;
60 rebuild();
61}
62
64{
68
69 if (!data.is_valid()) {
71 "SDFNode: no isosurface crossings at iso_level={}", m_iso_level);
72 clear_mesh();
73 m_dirty = false;
74 return;
75 }
76
77 set_mesh(data);
79 m_dirty = false;
80}
81
82} // namespace MayaFlux::Nodes::GpuSync
#define MF_WARN(comp, ctx,...)
void set_mesh(const Kakshya::MeshData &data)
Replace all vertex and index data from a MeshData owner.
void compute_frame() override
Compute GPU data for this frame.
Indexed triangle mesh for static or infrequently-updated geometry.
void set_field(Kinesis::SpatialField field)
Replace the scalar field and mark dirty.
Definition SDFNode.cpp:29
void set_bounds(const glm::vec3 &bounds_min, const glm::vec3 &bounds_max)
Replace the evaluation volume and mark dirty.
Definition SDFNode.cpp:35
SDFNode(Kinesis::SpatialField field, const glm::vec3 &bounds_min, const glm::vec3 &bounds_max, uint32_t res_x, uint32_t res_y, uint32_t res_z, float iso_level=0.0F)
Construct and evaluate the initial isosurface.
Definition SDFNode.cpp:9
void compute_frame() override
Re-extract the isosurface if dirty, then upload via parent.
Definition SDFNode.cpp:56
void set_resolution(uint32_t res_x, uint32_t res_y, uint32_t res_z)
Replace the grid resolution and mark dirty.
Definition SDFNode.cpp:42
Kinesis::SpatialField m_field
Definition SDFNode.hpp:103
void set_iso_level(float iso_level)
Replace the iso_level threshold and mark dirty.
Definition SDFNode.cpp:50
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.
MAYAFLUX_API Kakshya::MeshData generate_sdf_mesh(const Kinesis::SpatialField &field, const glm::vec3 &bounds_min, const glm::vec3 &bounds_max, uint32_t res_x, uint32_t res_y, uint32_t res_z, float iso_level=0.0F)
Extract an isosurface from a scalar field using marching cubes.
Typed, composable, stateless callable from domain D to range R.
Definition Tendency.hpp:22