Commit faf9e4cf authored by TheNumbat's avatar TheNumbat
Browse files

fix macos build; add wrapper for erase

parent 9bc17c6e
......@@ -190,6 +190,14 @@ public:
// Student Local Operations | student/meshedit.cpp
//////////////////////////////////////////////////////////////////////////////////////////
// Note: if you erase elements in these methods, they will not be erased from the
// element lists until do_erase or validate are called. This is to facilitate checking
// for dangling references to elements that will be erased.
// The rest of the codebase will automatically call validate() after each op,
// but you may need to be aware of this when implementing global ops.
// Specifically, when you need to collapse an edge in iostropic_remesh() or simplify(),
// you should call collapse_edge_erase() instead of collapse_edge()
/*
Merge all faces incident on a given vertex, returning a
pointer to the merged face.
......@@ -260,6 +268,16 @@ public:
void bevel_face_positions(const std::vector<Vec3> &start_positions, FaceRef face,
float tangent_offset, float normal_offset);
/*
Collapse an edge, returning a pointer to the collapsed vertex
** Also deletes the erased elements **
*/
std::optional<VertexRef> collapse_edge_erase(EdgeRef e) {
auto r = collapse_edge(e);
do_erase();
return r;
}
//////////////////////////////////////////////////////////////////////////////////////////
// Student Global Operations | student/meshedit.cpp
//////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -226,7 +226,6 @@ void Model::vertex_viz(Halfedge_Mesh::VertexRef v, float &size, Mat4 &transform)
auto he = v->halfedge();
do {
Vec3 n = he->twin()->vertex()->pos;
float len = he->edge()->length();
min = std::min(min, len);
avg += len;
......
......@@ -235,7 +235,7 @@ void Halfedge_Mesh::bevel_edge_positions(const std::vector<Vec3> &start_position
new_halfedges and vertex positions
in orig. So, you can write loops of the form
for(size_t i = 0; i < new_halfedges.size(); hs++)
for(size_t i = 0; i < new_halfedges.size(); i++)
{
Vec3 pi = start_positions[i]; // get the original vertex
position corresponding to vertex i
......@@ -430,6 +430,13 @@ bool Halfedge_Mesh::isotropic_remesh() {
// -> Now flip each edge if it improves vertex degree
// -> Finally, apply some tangential smoothing to the vertex positions
// Note: if you erase elements in a local operation, they will not be actually deleted
// until do_erase or validate are called. This is to facilitate checking
// for dangling references to elements that will be erased.
// The rest of the codebase will automatically call validate() after each op,
// but here simply calling collapse_edge() will not erase the elements.
// You should use collapse_edge_erase() instead for the desired behavior.
return false;
}
......@@ -549,5 +556,12 @@ bool Halfedge_Mesh::simplify() {
// a quadric to the collapsed vertex, and to pop the collapsed edge off the
// top of the queue.
// Note: if you erase elements in a local operation, they will not be actually deleted
// until do_erase or validate are called. This is to facilitate checking
// for dangling references to elements that will be erased.
// The rest of the codebase will automatically call validate() after each op,
// but here simply calling collapse_edge() will not erase the elements.
// You should use collapse_edge_erase() instead for the desired behavior.
return false;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment