diff --git a/src/ossia/dataflow/data_copy.hpp b/src/ossia/dataflow/data_copy.hpp index 8a55b5ce0f8..23a6c033d83 100644 --- a/src/ossia/dataflow/data_copy.hpp +++ b/src/ossia/dataflow/data_copy.hpp @@ -32,7 +32,10 @@ struct data_size std::size_t operator()(const audio_delay_line& p) const { return p.samples.size(); } - std::size_t operator()(const geometry_delay_line& p) const { return p.meshes.size(); } + std::size_t operator()(const geometry_delay_line& p) const + { + return p.geometries.size(); + } std::size_t operator()(const ossia::monostate&) const { return 0; } std::size_t operator()() const { return 0; } @@ -63,7 +66,7 @@ struct move_data { // OPTIMIZEME // if(out.flags & geometry_port::dirty_meshes) - in.meshes = out.meshes; //std::move(out.meshes); + in.geometry = out.geometry; //std::move(out.meshes); // if(out.flags & geometry_port::dirty_transform) in.transform = out.transform; in.flags = out.flags; @@ -158,23 +161,23 @@ struct copy_data { // Called in init_node_visitor::copy, when copying from a node to another //if(out.flags & geometry_port::dirty_meshes) - in.meshes = out.meshes; + in.geometry = out.geometry; //if(out.flags & geometry_port::dirty_transform) in.transform = out.transform; in.flags = out.flags; } - void operator()(const mesh_list_ptr& out, geometry_port& in) + void operator()(const geometry_spec& out, geometry_port& in) { // Called in copy_data_pos below - in.meshes = out; + in.geometry = out; } void operator()(const geometry_port& out, geometry_delay_line& in) { // Called in env_writer, when copying from a node to a delay line // if(out.flags & geometry_port::dirty_meshes) - in.meshes.push_back(out.meshes); + in.geometries.push_back(out.geometry); } }; @@ -212,9 +215,9 @@ struct copy_data_pos } void operator()(const geometry_delay_line& out, geometry_port& in) { - if(pos < out.meshes.size()) + if(pos < out.geometries.size()) { - copy_data{}(out.meshes[pos], in); + copy_data{}(out.geometries[pos], in); } } }; diff --git a/src/ossia/dataflow/geometry_port.hpp b/src/ossia/dataflow/geometry_port.hpp index 0117f71d4f9..1baf823bd96 100644 --- a/src/ossia/dataflow/geometry_port.hpp +++ b/src/ossia/dataflow/geometry_port.hpp @@ -105,6 +105,47 @@ struct transform3d }; }; +struct geometry_filter +{ + int64_t node_id{}; // which node is responsible for initalizing the UBO + int64_t filter_id{}; // unique index for this filter instance + /** + * @brief shader + * + * ``` + * layout(std140, binding = %next%) uniform filter_t { + * float v; + * } filter; + * void process_vertex(inout vec3 position, inout vec3 normal, inout vec2 uv, inout vec3 tangent, inout vec4 color) + * { + * position.xyz += v; + * } + * ``` + */ + std::string shader; + int64_t dirty_index{}; +}; + +struct geometry_filter_list +{ + std::vector filters; + int64_t dirty_index{}; +}; +using geometry_filter_list_ptr = std::shared_ptr; + +struct geometry_spec +{ + mesh_list_ptr meshes; + geometry_filter_list_ptr filters; + + operator bool() const noexcept { return meshes && filters; } + bool operator==(const geometry_spec&) const noexcept = default; + bool operator<(const geometry_spec& rhs) const noexcept + { + return (meshes < rhs.meshes) || (meshes == rhs.meshes && filters < rhs.filters); + } +}; + struct OSSIA_EXPORT geometry_port { static const constexpr int which = 4; @@ -116,14 +157,14 @@ struct OSSIA_EXPORT geometry_port void clear(); - mesh_list_ptr meshes; + geometry_spec geometry; transform3d transform; uint8_t flags{}; }; struct geometry_delay_line { - std::vector meshes; + std::vector geometries; }; } diff --git a/src/ossia/dataflow/port.hpp b/src/ossia/dataflow/port.hpp index 74c0e2a6685..79da473d442 100644 --- a/src/ossia/dataflow/port.hpp +++ b/src/ossia/dataflow/port.hpp @@ -531,7 +531,7 @@ inline T* inlet::target() noexcept { if(which() == 4) { - return static_cast(this)->data; + return &static_cast(this)->data; } else { @@ -595,7 +595,7 @@ inline T* outlet::target() noexcept { if(which() == 4) { - return static_cast(this)->data; + return &static_cast(this)->data; } else {