Skip to content

Commit

Permalink
[geom] Various geometry improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Aug 20, 2022
1 parent 83ed43b commit 87e3d96
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/ossia/dataflow/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ value_vector<ossia::timed_value>& value_port::get_data()
return data;
}

void geometry_port::clear() { }
void geometry_port::clear()
{
flags = {};
}

}
21 changes: 12 additions & 9 deletions src/ossia/dataflow/data_copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ 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.meshes.size(); }

std::size_t operator()(const ossia::monostate&) const { return 0; }
std::size_t operator()() const { return 0; }
Expand Down Expand Up @@ -65,8 +62,12 @@ struct move_data
void operator()(geometry_port& out, geometry_port& in)
{
// OPTIMIZEME
if(out.meshes.dirty)
if(out.flags & geometry_port::dirty_meshes)
in.meshes = std::move(out.meshes);
if(out.flags & geometry_port::dirty_transform)
in.transform = out.transform;
in.flags = out.flags;
out.flags = {};
}
};

Expand Down Expand Up @@ -156,21 +157,23 @@ struct copy_data
void operator()(const geometry_port& out, geometry_port& in)
{
// Called in init_node_visitor::copy, when copying from a node to another
if(out.meshes.dirty)
if(out.flags & geometry_port::dirty_meshes)
in.meshes = out.meshes;
if(out.flags & geometry_port::dirty_transform)
in.transform = out.transform;
in.flags = out.flags;
}

void operator()(const mesh_list& out, geometry_port& in)
{
// Called in copy_data_pos below
if(out.dirty)
in.meshes = out;
in.meshes = 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.meshes.dirty)
if(out.flags & geometry_port::dirty_meshes)
in.meshes.push_back(out.meshes);
}
};
Expand Down
16 changes: 13 additions & 3 deletions src/ossia/dataflow/geometry_port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,33 @@ struct geometry
uint32
} format{};
} index;

bool dirty{};
};

struct mesh_list
{
std::vector<geometry> meshes;
bool dirty{};
};

struct transform3d
{
float matrix[16]{
1., 0., 0., 0.,
0., 1., 0., 0.,
0., 0., 1., 0.,
0., 0., 0., 1.,
};
};

struct OSSIA_EXPORT geometry_port
{
static const constexpr int which = 4;
enum dirt_flags { dirty_transform = 0x1, dirty_meshes = 0x2 };

void clear();

mesh_list meshes;
transform3d transform;
uint8_t flags{};
};

struct geometry_delay_line
Expand Down

0 comments on commit 87e3d96

Please sign in to comment.