Commit 9ead25f6 by Philipp Adolf

Consider regular triangles for vertex table

parent 4093abb5
...@@ -157,7 +157,7 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) { ...@@ -157,7 +157,7 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
} }
precomputeEdgeTable(tables, triangles, triangles_regular, (unsigned int) vb.length()); precomputeEdgeTable(tables, triangles, triangles_regular, (unsigned int) vb.length());
precomputeVertexTable(tables, vb, ib); precomputeVertexTable(tables, vb, ib, ib_regular);
//tables.patch_index_regular = getPatchIndexBuffer(ib, QVector<unsigned int>());//TODO pass regular and irregular index buffer? //tables.patch_index_regular = getPatchIndexBuffer(ib, QVector<unsigned int>());//TODO pass regular and irregular index buffer?
qCDebug(log_subdiv) << "Precompute Tables Done"; qCDebug(log_subdiv) << "Precompute Tables Done";
...@@ -286,10 +286,11 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian ...@@ -286,10 +286,11 @@ void Subdivision::precomputeEdgeTable(Subdivision::Tables &tables, QVector<Trian
} }
} }
void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Vertex> &vb, QVector<unsigned int> &ib) { void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Vertex> &vb, QVector<unsigned int> &ib, QVector<unsigned int> &ib_regular) {
//compute vertex table //compute vertex table
//Format: First entry: original vertex. Other entries: adjacent vertices. //Format: First entry: original vertex. Other entries: adjacent vertices.
QVector<QVector<unsigned int> > duplicates;//for debugging QVector<QVector<unsigned int> > duplicates;//for debugging
QVector<unsigned int> ib_combined = ib + ib_regular;
unsigned int offset = 0; unsigned int offset = 0;
for (int i = 0; i < vb.length(); i++){ for (int i = 0; i < vb.length(); i++){
//hat evtl viel redundanz //hat evtl viel redundanz
...@@ -303,21 +304,21 @@ void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Ver ...@@ -303,21 +304,21 @@ void Subdivision::precomputeVertexTable(Subdivision::Tables &tables, QVector<Ver
QVector<unsigned int> d; QVector<unsigned int> d;
for (int j = 0; j < ib.length(); j++){ for (int j = 0; j < ib_combined.length(); j++){
//suche verweise auf vertex im indexbuffer //suche verweise auf vertex im indexbuffer
if (vb[ib[j]].samePos(originalVertex)){ if (vb[ib_combined[j]].samePos(originalVertex)){
d.push_back(j); d.push_back(j);
unsigned int i1, i2; //indices for neighbour vertices unsigned int i1, i2; //indices for neighbour vertices
if(j%3==0){ if(j%3==0){
i1 = ib[j+1]; i1 = ib_combined[j+1];
i2 = ib[j+2]; i2 = ib_combined[j+2];
} else if(j%3==1){ } else if(j%3==1){
i1 = ib[j-1]; i1 = ib_combined[j-1];
i2 = ib[j+1]; i2 = ib_combined[j+1];
} else{ } else{
i1 = ib[j-2]; i1 = ib_combined[j-2];
i2 = ib[j-1]; i2 = ib_combined[j-1];
} }
Vertex v1,v2; //neighbour vertices; Vertex v1,v2; //neighbour vertices;
......
...@@ -55,7 +55,7 @@ private: ...@@ -55,7 +55,7 @@ private:
QOpenGLShaderProgram *initComputeShaderProgram(QString &source); QOpenGLShaderProgram *initComputeShaderProgram(QString &source);
Tables precomputeTables(Input input); Tables precomputeTables(Input input);
void precomputeEdgeTable(Subdivision::Tables &tables, QVector<Triangle> &triangles, QVector<Triangle> &triangles_regular, 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 precomputeVertexTable(Subdivision::Tables &tables, QVector<Vertex> &vb, QVector<unsigned int> &ib, QVector<unsigned int> &ib_regular);
void findRegular(QVector<unsigned int> index_buffer, QVector<Vertex> vertex_buffer, QVector<unsigned int> &regular, QVector<unsigned int> &irregular); 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); Result runShader(Input input, Tables &tables);
void runVertexShader(GLuint size, GLuint vb_handle, GLuint vertex_indices_handle, GLuint vertex_offsets_handle, GLuint output_handle); void runVertexShader(GLuint size, GLuint vb_handle, GLuint vertex_indices_handle, GLuint vertex_offsets_handle, GLuint output_handle);
......
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