Commit 9fe1af47 by Philipp Adolf

temp

parent 1e95e175
...@@ -145,7 +145,7 @@ void MainWidget::initializeGL(){ ...@@ -145,7 +145,7 @@ void MainWidget::initializeGL(){
subdivision->init(); subdivision->init();
//loadNewMesh( "../Models/demon_head.3ds"); //loadNewMesh( "../Models/demon_head.3ds");
loadNewMesh( "../Models/torus.obj"); loadNewMesh( "../Models/box.obj");
} }
void MainWidget::loadNewMesh(){ void MainWidget::loadNewMesh(){
......
...@@ -550,74 +550,90 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian ...@@ -550,74 +550,90 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
extra_it.next(); extra_it.next();
Triangle triangle = extra_it.key(); Triangle triangle = extra_it.key();
qDebug() << triangle; qDebug() << triangle;
unsigned int uv, vw, wu; int uv = -1;
int vw = -1;
int wu = -1;
Edge edge; Edge edge;
Triangle::Neighbors ns = neighbors.value(triangle); Triangle::Neighbors ns = neighbors.value(triangle);
edge = { triangle.u_idx(), triangle.v_idx() }; if (ns.uv.triangle != NULL) {
if (edge_indices.contains(edge)) { edge = { triangle.u_idx(), triangle.v_idx() };
uv = edge_indices.value(edge); if (edge_indices.contains(edge)) {
} else { uv = edge_indices.value(edge);
uv = offset++; } else {
edge_indices.insert(edge, uv); uv = offset++;
edge_indices.insert(edge, uv);
edge = { ns.uv.edge.a, ns.uv.edge.b };
edge_indices.insert(edge, uv); edge = { ns.uv.edge.a, ns.uv.edge.b };
edge_indices.insert(edge, uv);
tables.edge_indices.push_back(triangle.u_idx());
tables.edge_indices.push_back(triangle.v_idx()); tables.edge_indices.push_back(triangle.u_idx());
tables.edge_indices.push_back(triangle.w_idx()); tables.edge_indices.push_back(triangle.v_idx());
tables.edge_indices.push_back(ns.uv.edge.c); tables.edge_indices.push_back(triangle.w_idx());
tables.edge_indices.push_back(ns.uv.edge.c);
}
} }
edge = { triangle.v_idx(), triangle.w_idx() }; if (ns.vw.triangle != NULL) {
if (edge_indices.contains(edge)) { edge = { triangle.v_idx(), triangle.w_idx() };
vw = edge_indices.value(edge); if (edge_indices.contains(edge)) {
} else { vw = edge_indices.value(edge);
vw = offset++; } else {
edge_indices.insert(edge, vw); vw = offset++;
edge_indices.insert(edge, vw);
edge = { ns.vw.edge.a, ns.vw.edge.b };
edge_indices.insert(edge, vw); edge = { ns.vw.edge.a, ns.vw.edge.b };
edge_indices.insert(edge, vw);
tables.edge_indices.push_back(triangle.v_idx());
tables.edge_indices.push_back(triangle.w_idx()); tables.edge_indices.push_back(triangle.v_idx());
tables.edge_indices.push_back(triangle.u_idx()); tables.edge_indices.push_back(triangle.w_idx());
tables.edge_indices.push_back(ns.vw.edge.c); tables.edge_indices.push_back(triangle.u_idx());
tables.edge_indices.push_back(ns.vw.edge.c);
}
} }
edge = { triangle.w_idx(), triangle.u_idx() }; if (ns.wu.triangle != NULL) {
if (edge_indices.contains(edge)) { edge = { triangle.w_idx(), triangle.u_idx() };
wu = edge_indices.value(edge); if (edge_indices.contains(edge)) {
} else { wu = edge_indices.value(edge);
wu = offset++; } else {
edge_indices.insert(edge, wu); wu = offset++;
edge_indices.insert(edge, wu);
edge = { ns.wu.edge.a, ns.wu.edge.b };
edge_indices.insert(edge, wu); edge = { ns.wu.edge.a, ns.wu.edge.b };
edge_indices.insert(edge, wu);
tables.edge_indices.push_back(triangle.w_idx());
tables.edge_indices.push_back(triangle.u_idx()); tables.edge_indices.push_back(triangle.w_idx());
tables.edge_indices.push_back(triangle.v_idx()); tables.edge_indices.push_back(triangle.u_idx());
tables.edge_indices.push_back(ns.wu.edge.c); tables.edge_indices.push_back(triangle.v_idx());
tables.edge_indices.push_back(ns.wu.edge.c);
}
} }
tables.extra_triangles.push_back(triangle.u_idx()); if (uv >= 0 && wu >= 0) {
tables.extra_triangles.push_back(uv); tables.extra_triangles.push_back(triangle.u_idx());
tables.extra_triangles.push_back(wu); tables.extra_triangles.push_back(uv);
tables.extra_triangles.push_back(wu);
}
tables.extra_triangles.push_back(triangle.v_idx()); if (vw >= 0 && uv >= 0) {
tables.extra_triangles.push_back(vw); tables.extra_triangles.push_back(triangle.v_idx());
tables.extra_triangles.push_back(uv); tables.extra_triangles.push_back(vw);
tables.extra_triangles.push_back(uv);
}
tables.extra_triangles.push_back(triangle.w_idx()); if (wu >= 0 && vw >= 0) {
tables.extra_triangles.push_back(wu); tables.extra_triangles.push_back(triangle.w_idx());
tables.extra_triangles.push_back(vw); tables.extra_triangles.push_back(wu);
tables.extra_triangles.push_back(vw);
}
tables.extra_triangles.push_back(uv); if (uv >= 0 && vw >= 0 && wu >= 0) {
tables.extra_triangles.push_back(vw); tables.extra_triangles.push_back(uv);
tables.extra_triangles.push_back(wu); tables.extra_triangles.push_back(vw);
tables.extra_triangles.push_back(wu);
}
} }
qCDebug(log_subdiv) << "Done with edge table. " << tables.edge_indices.length(); qCDebug(log_subdiv) << "Done with edge table. " << tables.edge_indices.length();
......
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