Skip to content

Commit

Permalink
[geometry] Rework for filter lists
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Nov 12, 2024
1 parent 6e2716c commit fad429e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
19 changes: 11 additions & 8 deletions src/ossia/dataflow/data_copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
};

Expand Down Expand Up @@ -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);
}
}
};
Expand Down
45 changes: 43 additions & 2 deletions src/ossia/dataflow/geometry_port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<geometry_filter> filters;
int64_t dirty_index{};
};
using geometry_filter_list_ptr = std::shared_ptr<geometry_filter_list>;

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;
Expand All @@ -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<mesh_list_ptr> meshes;
std::vector<geometry_spec> geometries;
};

}
4 changes: 2 additions & 2 deletions src/ossia/dataflow/port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ inline T* inlet::target() noexcept
{
if(which() == 4)
{
return static_cast<geometry_inlet*>(this)->data;
return &static_cast<geometry_inlet*>(this)->data;
}
else
{
Expand Down Expand Up @@ -595,7 +595,7 @@ inline T* outlet::target() noexcept
{
if(which() == 4)
{
return static_cast<geometry_outlet*>(this)->data;
return &static_cast<geometry_outlet*>(this)->data;
}
else
{
Expand Down

0 comments on commit fad429e

Please sign in to comment.