Commit 9fe1af47 by Philipp Adolf

temp

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