Commit faf9e4cf authored by TheNumbat's avatar TheNumbat
Browse files

fix macos build; add wrapper for erase

parent 9bc17c6e
...@@ -190,6 +190,14 @@ public: ...@@ -190,6 +190,14 @@ public:
// Student Local Operations | student/meshedit.cpp // 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 Merge all faces incident on a given vertex, returning a
pointer to the merged face. pointer to the merged face.
...@@ -260,6 +268,16 @@ public: ...@@ -260,6 +268,16 @@ public:
void bevel_face_positions(const std::vector<Vec3> &start_positions, FaceRef face, void bevel_face_positions(const std::vector<Vec3> &start_positions, FaceRef face,
float tangent_offset, float normal_offset); 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 // Student Global Operations | student/meshedit.cpp
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
......
...@@ -226,7 +226,6 @@ void Model::vertex_viz(Halfedge_Mesh::VertexRef v, float &size, Mat4 &transform) ...@@ -226,7 +226,6 @@ void Model::vertex_viz(Halfedge_Mesh::VertexRef v, float &size, Mat4 &transform)
auto he = v->halfedge(); auto he = v->halfedge();
do { do {
Vec3 n = he->twin()->vertex()->pos;
float len = he->edge()->length(); float len = he->edge()->length();
min = std::min(min, len); min = std::min(min, len);
avg += len; avg += len;
......
...@@ -235,7 +235,7 @@ void Halfedge_Mesh::bevel_edge_positions(const std::vector<Vec3> &start_position ...@@ -235,7 +235,7 @@ void Halfedge_Mesh::bevel_edge_positions(const std::vector<Vec3> &start_position
new_halfedges and vertex positions new_halfedges and vertex positions
in orig. So, you can write loops of the form 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 Vec3 pi = start_positions[i]; // get the original vertex
position corresponding to vertex i position corresponding to vertex i
...@@ -430,6 +430,13 @@ bool Halfedge_Mesh::isotropic_remesh() { ...@@ -430,6 +430,13 @@ bool Halfedge_Mesh::isotropic_remesh() {
// -> Now flip each edge if it improves vertex degree // -> Now flip each edge if it improves vertex degree
// -> Finally, apply some tangential smoothing to the vertex positions // -> 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; return false;
} }
...@@ -549,5 +556,12 @@ bool Halfedge_Mesh::simplify() { ...@@ -549,5 +556,12 @@ bool Halfedge_Mesh::simplify() {
// a quadric to the collapsed vertex, and to pop the collapsed edge off the // a quadric to the collapsed vertex, and to pop the collapsed edge off the
// top of the queue. // 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; 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