Commit 1cbbace4 by Philipp Adolf

temp

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