Commit d2a58635 by Philipp Adolf

Allow precomputeEdgeTable to return extra triangles

parent 0415637a
...@@ -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";
......
...@@ -34,6 +34,7 @@ private: ...@@ -34,6 +34,7 @@ private:
QVector<GLuint> vertex_offsets; QVector<GLuint> vertex_offsets;
QVector<GLuint> index_buffer; QVector<GLuint> index_buffer;
QVector<GLuint> patch_index_regular; QVector<GLuint> patch_index_regular;
QVector<GLuint> extra_triangles;
}; };
struct Result struct Result
......
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