Commit 5941405e authored by allai5's avatar allai5
Browse files

Merge branch 'master' of https://github.com/CMU-Graphics/Scotty3D

parents 519bc2c1 8ddfb4bf
......@@ -557,7 +557,7 @@ bool Halfedge_Mesh::subdivide(SubD strategy) {
Index idx = 0;
size_t nV = vertices.size();
size_t nE = edges.size();
size_t nF = faces.size();
size_t nF = faces.size() - n_boundaries();
verts.resize(nV + nE + nF);
for(VertexRef v = vertices_begin(); v != vertices_end(); v++, idx++) {
......@@ -568,12 +568,15 @@ bool Halfedge_Mesh::subdivide(SubD strategy) {
verts[idx] = e->new_pos;
layout[e->id()] = idx;
}
for(FaceRef f = faces_begin(); f != faces_end(); f++, idx++) {
for(FaceRef f = faces_begin(); f != faces_end(); f++) {
if(f->is_boundary()) continue;
verts[idx] = f->new_pos;
layout[f->id()] = idx;
idx++;
}
for(auto f = faces_begin(); f != faces_end(); f++) {
if(f->is_boundary()) continue;
Index i = layout[f->id()];
HalfedgeRef h = f->halfedge();
do {
......
......@@ -200,24 +200,32 @@ Data cone(float bradius, float tradius, float height, int sides, bool caps) {
size_t vert = 0;
vertices[vert++] = Vec3(0.0f, 0.0f, 0.0f);
float t = 0.0f;
float step = _2pi / n_sides;
while(vert <= n_sides) {
float rad = (float)vert / n_sides * _2pi;
vertices[vert] = Vec3(std::cos(rad) * bradius, 0.0f, std::sin(rad) * bradius);
vertices[vert] = Vec3(std::cos(t) * bradius, 0.0f, std::sin(t) * bradius);
vert++;
t += step;
}
vertices[vert++] = Vec3(0.0f, height, 0.0f);
t = 0.0f;
while(vert <= n_sides * 2 + 1) {
float rad = (float)(vert - n_sides - 1) / n_sides * _2pi;
vertices[vert] = Vec3(std::cos(rad) * tradius, height, std::sin(rad) * tradius);
vertices[vert] = Vec3(std::cos(t) * tradius, height, std::sin(t) * tradius);
vert++;
t += step;
}
size_t v = 0;
t = 0.0f;
while(vert <= vertices.size() - 4) {
float rad = (float)v / n_sides * _2pi;
vertices[vert] = Vec3(std::cos(rad) * tradius, height, std::sin(rad) * tradius);
vertices[vert + 1] = Vec3(std::cos(rad) * bradius, 0.0f, std::sin(rad) * bradius);
vertices[vert] = Vec3(std::cos(t) * tradius, height, std::sin(t) * tradius);
vertices[vert + 1] = Vec3(std::cos(t) * bradius, 0.0f, std::sin(t) * bradius);
vert += 2;
v++;
t += step;
}
vertices[vert] = vertices[n_sides * 2 + 2];
vertices[vert + 1] = vertices[n_sides * 2 + 3];
......
......@@ -253,7 +253,7 @@ void Model::edge_viz(Halfedge_Mesh::EdgeRef e, Mat4& transform) {
float v0s = vert_sizes[v_0->id()], v1s = vert_sizes[v_1->id()];
float s = 0.5f * std::min(v0s, v1s);
if(dir.y == 1.0f || dir.y == -1.0f) {
if(1.0f - std::abs(dir.y) < EPS_F) {
l *= sign(dir.y);
transform = Mat4{Vec4{s, 0.0f, 0.0f, 0.0f}, Vec4{0.0f, l, 0.0f, 0.0f},
Vec4{0.0f, 0.0f, s, 0.0f}, Vec4{v0, 1.0f}};
......@@ -381,6 +381,16 @@ void Model::rebuild() {
// Create cylinder for each edge
cylinders.clear();
for(auto e = mesh.edges_begin(); e != mesh.edges_end(); e++) {
// We don't want to render edges between two boundary faces, since the boundaries
// should look contiguous
if(e->halfedge()->is_boundary() && e->halfedge()->twin()->is_boundary()) {
// Unless both surrounding boundaries are the same face, in which case we should
// render this edge to show that the next vertex is connected
if(e->halfedge()->face() != e->halfedge()->twin()->face())
continue;
}
Mat4 transform;
edge_viz(e, transform);
......
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