Commit 1cbbace4 by Philipp Adolf

temp

parent 0b31a5fa
......@@ -89,15 +89,18 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
Tables tables = precomputeTables(input);
Result result = runShader(input, tables);
QVector<Triangle> triangles;
ibToTriangles(&result.vertex_buffer, tables.index_buffer, triangles);
QVector<Triangle> all_triangles;
ibToTriangles(&result.vertex_buffer, tables.index_buffer, all_triangles);
ibToTriangles(&result.vertex_buffer, tables.extra_triangles, all_triangles);
all_triangles += triangles;
QMap<Triangle, Triangle::Neighbors> neighbors;
buildNeighborsMap(result.vertex_buffer, all_triangles, neighbors);
QVector<Triangle> regular;
QVector<Triangle> irregular;
findRegular(all_triangles, neighbors, regular, irregular);
findRegular(triangles, neighbors, regular, irregular);
qCDebug(log_subdiv) << "Indices" << tables.index_buffer.length();
qCDebug(log_subdiv) << "subdivide: regular" << regular.length();
......@@ -177,6 +180,7 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
subTimer.restart();
updateIndexBuffer(tables.index_buffer, modified_vertices);
updateIndexBuffer(tables.extra_triangles, modified_vertices);
qCDebug(log_timing) << "updateIndexBuffer:" << formatTimeMeasurement(subTimer.elapsed());
qCDebug(log_subdiv) << "Precompute Tables Done";
......@@ -410,14 +414,16 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
*/
Triangle::Neighbors ns = neighbors.value(*triangle);
if (!irregular_triangles.contains(*ns.uv.triangle)) {
extra_triangles.insert(*ns.uv.triangle, true);
}
if (!irregular_triangles.contains(*ns.vw.triangle)) {
extra_triangles.insert(*ns.vw.triangle, true);
}
if (!irregular_triangles.contains(*ns.wu.triangle)) {
extra_triangles.insert(*ns.wu.triangle, true);
QVector<Triangle> neighboring_triangles;
neighboring_triangles += vertexNeighbors(*triangle, ns.uv, neighbors);
neighboring_triangles += vertexNeighbors(*triangle, ns.vw, neighbors);
neighboring_triangles += vertexNeighbors(*triangle, ns.wu, neighbors);
QVectorIterator<Triangle> extra(neighboring_triangles);
while (extra.hasNext()) {
Triangle extra_triangle = extra.next();
if (!irregular_triangles.contains(extra_triangle)) {
extra_triangles.insert(extra_triangle, true);
}
}
// indices of the three vertices added to the edges of this triangle
......@@ -491,10 +497,13 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
tables.index_buffer.push_back(wu);
}
qDebug() << "extra triangles" << extra_triangles.size();
QMapIterator<Triangle, bool> extra_it(extra_triangles);
while (extra_it.hasNext()) {
extra_it.next();
Triangle triangle = extra_it.key();
qDebug() << triangle;
unsigned int uv, vw, wu;
Edge edge;
......
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