Commit 4093abb5 by Philipp Adolf

Consider regular triangles for edge table

parent d14dc5a6
......@@ -156,7 +156,7 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
triangles.push_back(Triangle(vb, ib_regular[i], ib_regular[i+1], ib_regular[i+2]));
}
precomputeEdgeTable(tables, triangles, (unsigned int) vb.length());
precomputeEdgeTable(tables, triangles, triangles_regular, (unsigned int) vb.length());
precomputeVertexTable(tables, vb, ib);
//tables.patch_index_regular = getPatchIndexBuffer(ib, QVector<unsigned int>());//TODO pass regular and irregular index buffer?
......@@ -164,7 +164,7 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
return tables;
}
void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Triangle> &triangles, unsigned int offset) {
void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Triangle> &triangles, QVector<Triangle> &triangles_regular, unsigned int offset) {
//compute edge table
//Format: first two entries: edge vertices. last two entries: distant vertices.
......@@ -196,6 +196,12 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
insert_edge(opposite_edges, triangles[j], edge_b, edge_a);
}
}
for (int j = 0; j < triangles_regular.length(); j++){
if (triangle.get_shared_edge(triangles_regular[j], edge_a, edge_b)) {
insert_edge(opposite_edges, triangle, edge_a, edge_b);
// no need to insert the opposite edge of a regular triangle - it won't be processed by the outer loop
}
}
QVector<Triangle::Edge> opposite = opposite_edges.value(triangle);
......
......@@ -54,7 +54,7 @@ private:
QOpenGLShaderProgram *initComputeShaderProgram(QString &source);
Tables precomputeTables(Input input);
void precomputeEdgeTable(Subdivision::Tables &tables, QVector<Triangle> &triangles, unsigned int offset);
void precomputeEdgeTable(Subdivision::Tables &tables, QVector<Triangle> &triangles, QVector<Triangle> &triangles_regular, unsigned int offset);
void precomputeVertexTable(Subdivision::Tables &tables, QVector<Vertex> &vb, QVector<unsigned int> &ib);
void findRegular(QVector<unsigned int> index_buffer, QVector<Vertex> vertex_buffer, QVector<unsigned int> &regular, QVector<unsigned int> &irregular);
Result runShader(Input input, Tables &tables);
......
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