2 #include <ossia/dataflow/graph_node.hpp>
3 #include <ossia/dataflow/nodes/spline/spline2d.hpp>
4 #include <ossia/dataflow/nodes/spline/spline3d.hpp>
5 #include <ossia/dataflow/port.hpp>
8 #include <ossia/editor/automation/tinyspline_util.hpp>
11 namespace ossia::nodes
14 class spline final :
public ossia::nonowning_graph_node
17 spline() { m_outlets.push_back(&value_out); }
19 ~spline()
override =
default;
21 std::string label() const noexcept
override {
return "spline"; }
23 void set_spline(
const spline_data& t)
26 reinterpret_cast<const tsReal*
>(t.points.data()), t.points.size());
30 void run(
const ossia::token_request& t, ossia::exec_state_facade e) noexcept
override
35 ossia::value_port& vp = *value_out;
38 const auto [res_x, res_y] = m_spline.evaluate(pos);
40 const auto [tick_start, d] = e.timings(t);
43 ossia::make_vec(m_x + m_scaleX * res_x, m_y + m_scaleY * res_y), tick_start);
46 ossia::value_outlet value_out;
47 ts::spline<2> m_spline;
49 static constexpr
double m_scaleX{1.}, m_scaleY{1.};
52 class spline3d final :
public ossia::nonowning_graph_node
55 spline3d() { m_outlets.push_back(&value_out); }
57 ~spline3d()
override =
default;
59 std::string label() const noexcept
override {
return "spline"; }
61 void set_spline(
const spline3d_data& t)
64 reinterpret_cast<const tsReal*
>(t.points.data()), t.points.size());
68 void run(
const ossia::token_request& t, ossia::exec_state_facade e) noexcept
override
73 ossia::value_port& vp = *value_out;
76 const auto [res_x, res_y, res_z] = m_spline.evaluate(pos);
78 const auto [tick_start, d] = e.timings(t);
82 m_x + m_scaleX * res_x, m_y + m_scaleY * res_y, m_z + m_scaleZ * res_z),
86 ossia::value_outlet value_out;
87 ts::spline<3> m_spline;
88 double m_x{}, m_y{}, m_z{};
89 static constexpr
double m_scaleX{1.}, m_scaleY{1.}, m_scaleZ{1.};
constexpr OSSIA_INLINE T clamp(T d, const T min, const T max) noexcept
clamp Returns the value bounded by a min and a max
Definition: math.hpp:154
double tsReal
Definition: tinyspline.h:213