12 Eigen::Index samples_per_segment)
13 : m_default_mode(mode)
14 , m_default_samples_per_segment(samples_per_segment)
17 "PathOperator created with mode {}, {} samples per segment",
18 static_cast<int>(mode), samples_per_segment);
27 if (vertices.empty()) {
29 "Cannot initialize PathOperator with zero vertices");
37 "PathOperator initialized with {} control vertices", vertices.size());
45 const std::vector<std::vector<LineVertex>>& paths,
48 for (
const auto& path : paths) {
53 "PathOperator initialized with {} paths",
58 const std::vector<LineVertex>& control_vertices,
61 if (control_vertices.empty()) {
63 "Cannot add path with zero control vertices");
67 auto path = std::make_shared<GpuSync::PathGeneratorNode>(
72 path->set_control_points(control_vertices);
74 path->compute_frame();
76 m_paths.push_back(std::move(path));
79 "Added path #{} with {} control vertices, {} generated vertices",
80 m_paths.size(), control_vertices.size(),
81 m_paths.back()->get_generated_vertex_count());
95 path->compute_frame();
105 std::vector<LineVertex> positions;
107 for (
const auto& path :
m_paths) {
108 auto points = path->get_all_vertices();
109 for (
const auto& pt : points) {
110 positions.push_back(pt);
122 return m_paths[idx]->get_vertex_data();
128 for (
const auto& group :
m_paths) {
129 auto span = group->get_vertex_data();
132 span.begin(), span.end());
143 auto layout_opt =
m_paths[0]->get_vertex_layout();
154 for (
const auto& path :
m_paths) {
155 total += path->get_vertex_count();
162 return std::ranges::any_of(
164 [](
const auto& group) {
return group->needs_gpu_update(); });
170 path->clear_gpu_update_flag();
177 for (
const auto& path :
m_paths) {
178 total += path->get_all_vertex_count();
189 if (param ==
"tension") {
191 path->set_tension(value);
193 }
else if (param ==
"samples_per_segment") {
196 path->set_samples_per_segment(
static_cast<Eigen::Index
>(value));
198 }
else if (param ==
"thickness") {
208 if (query ==
"control_point_count") {
211 if (query ==
"vertex_count") {
214 if (query ==
"path_count") {
215 return static_cast<double>(
m_paths.size());
228 path->set_samples_per_segment(samples);
235 path->set_tension(tension);
243 path->set_path_thickness(thickness);
250 path->set_path_color(color);
258 const auto& vertices = group->get_all_vertices();
259 if (global_index < offset + vertices.size()) {
260 size_t local_index = global_index - offset;
261 return const_cast<LineVertex*
>(&vertices[local_index]);
263 offset += vertices.size();
#define MF_WARN(comp, ctx,...)
#define MF_DEBUG(comp, ctx,...)
void set_parameter(std::string_view param, double value) override
Set operator parameter.
void * get_data_at(size_t global_index) override
Get mutable access to point at global index.
std::vector< uint8_t > m_vertex_data_aggregate
Kinesis::InterpolationMode m_default_mode
void add_path(const std::vector< LineVertex > &control_vertices, Kinesis::InterpolationMode mode)
Add a new path with given control points and properties.
bool is_vertex_data_dirty() const override
Check if geometry changed this frame.
void initialize_paths(const std::vector< std::vector< LineVertex > > &paths, Kinesis::InterpolationMode mode)
Initialize multiple paths with given control points and properties.
std::vector< std::shared_ptr< GpuSync::PathGeneratorNode > > m_paths
Eigen::Index m_default_samples_per_segment
void set_tension(double tension)
Set the tension parameter for all paths (if supported by mode).
float m_default_thickness
size_t get_vertex_count() const override
Get number of vertices (may differ from point count for topology/path)
PathOperator(Kinesis::InterpolationMode mode=Kinesis::InterpolationMode::CATMULL_ROM, Eigen::Index samples_per_segment=32)
size_t get_point_count() const override
Get source point count (before topology expansion)
Kakshya::VertexLayout get_vertex_layout() const override
Get vertex layout describing vertex structure.
void set_samples_per_segment(Eigen::Index samples)
Set the number of samples per segment for all paths.
void set_global_color(const glm::vec3 &color)
Set the global color tint for all paths.
void initialize(const std::vector< LineVertex > &vertices)
Initialize a single path with given control points and properties.
void process(float dt) override
Process for one batch cycle.
void mark_vertex_data_clean() override
Clear dirty flag after GPU upload.
std::span< const uint8_t > get_vertex_data_for_collection(uint32_t idx) const override
Get vertex data for specific collection (if multiple)
std::vector< LineVertex > extract_vertices() const
Extract current vertex data as LineVertex array.
void set_global_thickness(float thickness)
Set the global thickness for all paths.
std::span< const uint8_t > get_vertex_data() const override
Get vertex data for GPU upload.
std::optional< double > query_state(std::string_view query) const override
Query operator internal state.
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.
InterpolationMode
Mathematical interpolation methods.
Complete description of vertex data layout in a buffer.