MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ build_interpolated_path()

void MayaFlux::Nodes::GpuSync::TopologyGeneratorNode::build_interpolated_path ( std::span< LineVertex >  points,
size_t  num_points 
)
private

Definition at line 407 of file TopologyGeneratorNode.cpp.

410{
412
413 m_control_scratch.resize(num_points * 3);
414 for (size_t i = 0; i < num_points; ++i) {
415 m_control_scratch[i * 3 + 0] = points[i].position.x;
416 m_control_scratch[i * 3 + 1] = points[i].position.y;
417 m_control_scratch[i * 3 + 2] = points[i].position.z;
418 }
419
420 const size_t num_segments = num_points - 1;
421 const auto total_samples = static_cast<Eigen::Index>(
422 1 + num_segments * (m_samples_per_segment - 1));
423
426
427 const std::vector<double>* curve = &m_curve_primary;
428
431 total_samples, total_samples, m_curve_secondary);
432 curve = &m_curve_secondary;
433 }
434
435 const auto count = static_cast<size_t>(total_samples);
436 if (count < 2) {
437 return;
438 }
439
440 m_vertices.resize((count - 1) * 2);
441
442 const double* x = curve->data();
443 const double* y = x + count;
444 const double* z = y + count;
445
448 }
449
450 const double* tx = m_curve_tangents.data();
451 const double* ty = tx + count;
452 const double* tz = ty + count;
453
454 const auto sample = [&](size_t s) {
455 return glm::vec3 {
456 static_cast<float>(x[s]), static_cast<float>(y[s]), static_cast<float>(z[s])
457 };
458 };
459
460 const auto tangent = [&](size_t s) {
461 return glm::vec3 {
462 static_cast<float>(tx[s]), static_cast<float>(ty[s]), static_cast<float>(tz[s])
463 };
464 };
465
466 for (size_t i = 0; i + 1 < count; ++i) {
467 m_vertices[i * 2].position = sample(i);
468 m_vertices[i * 2].tangent = tangent(i);
469 m_vertices[i * 2 + 1].position = sample(i + 1);
470 m_vertices[i * 2 + 1].tangent = tangent(i + 1);
471 }
472
473 write_path_attributes(points, num_points);
474}
std::vector< glm::vec2 > * points
uint32_t tangent
size_t count
void evaluate_planar(std::span< const double > control_points, size_t dim, Eigen::Index num_samples, std::vector< double > &out, std::vector< double > &tangents)
Evaluate a curve into coordinate-major position and tangent buffers.
void reparameterize_planar(std::span< const double > points, size_t dim, Eigen::Index point_count, Eigen::Index num_samples, std::vector< double > &out)
Resample a polyline to uniform arc length, coordinate-major.
void configure(InterpolationMode mode, double tension)
Re-resolve the kernel.
void write_path_attributes(std::span< const LineVertex > points, size_t num_points)
Write colour and thickness for the interpolated path.
size_t m_samples_per_segment
Controls smoothness vs performance.
void central_difference_tangents(std::span< const double > points, size_t dim, size_t count, std::vector< double > &tangents)
Tangents of a sampled curve by finite difference, coordinate-major.

References MayaFlux::Kinesis::central_difference_tangents(), MayaFlux::Kinesis::CurveEvaluator::configure(), count, MayaFlux::Kinesis::CurveEvaluator::evaluate_planar(), m_control_scratch, m_curve_primary, m_curve_secondary, m_curve_tangents, m_evaluator, m_path_interpolation_mode, m_samples_per_segment, m_use_arc_length_reparameterization, m_vertices, points, MayaFlux::Kinesis::CurveEvaluator::reparameterize_planar(), tangent, and write_path_attributes().

Referenced by build_vertex_buffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: