Commit 960e75ea by Alisa Jung

vertexIndices: Array of single indices with array with offsets instead of one…

vertexIndices: Array of single indices with array with offsets instead of one array with index-vectors
parent 1360526f
......@@ -48,12 +48,15 @@ QOpenGLShaderProgram *Subdivision::initEdgeComputeShaderProgram(){
Mesh *Subdivision::subdivide(Mesh *mesh) {
QVector<QVector<unsigned int> > edgeIndices;
precomputeTables(mesh, edgeIndices);
QVector<unsigned int> vertexIndices;
QVector<unsigned int> vertexIndicesOffsets;
precomputeTables(mesh, edgeIndices, vertexIndices, vertexIndicesOffsets);
runShader(mesh, edgeIndices);
return NULL;
}
void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &edgeIndices_base) {
void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &edgeIndices_base,
QVector<unsigned int> &vertexIndices, QVector<unsigned int> &vertexIndicesOffsets) {
Mesh::Node root = mesh->getRootNode();
int firstMeshEntryIndex = -1;
......@@ -193,18 +196,17 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
}
}
//TODO save/return edge table
//compute vertex table
//Format: First entry: original vertex. Other entries: adjacent vertices.
QVector<QVector<unsigned int> > vertexIndices_base;
QVector<QVector<unsigned int> > duplicates;//for debugging
int offset = 0;
for (unsigned int i = 0; i < vb.length(); i++){
//hat evtl viel redundanz
QVector<unsigned int> adjacent_indices;
QVector<Vertex> adj_v;//helfer
adjacent_indices.push_back(i);
vertexIndicesOffsets.push_back(offset);
vertexIndices.push_back(i);
offset++;
Vertex originalVertex = vb[i];
......@@ -230,7 +232,7 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
Vertex v1,v2; //neighbour vertices;
v1 = vb[i1];
v2 = vb[i2];
//check if vertices where already used
//check if vertices where already used to influence this vertex
//Note: Can't use contain. Contain uses equal (would have to implement equal, but we're only interested in the position here.
bool found1 = false;
bool found2 = false;
......@@ -240,23 +242,21 @@ void Subdivision::precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &
}
if (!found1){
adj_v.push_back(v1);
adjacent_indices.push_back(i1);
vertexIndices.push_back(i1);
offset++;
}
if (!found2){
adj_v.push_back(v2);
adjacent_indices.push_back(i2);
vertexIndices.push_back(i2);
offset++;
}
//if one adjacent vertex is referenced by multiple different indices, only its first index will appear in the adjacent_indices list.1
}
}
vertexIndices_base.push_back(adjacent_indices);
if (!duplicates.contains(d)) duplicates.push_back(d);
}
qDebug()<<"Done with vertex index table. "<<vertexIndices_base.length()<<" vertices processed. Table:";
for(int i = 0; i < vertexIndices_base.length(); i++){
qDebug()<<vertexIndices_base[i];
}
qDebug()<<"Done with vertex index table. ";
qDebug()<<"Duplicates: ";
for (int i = 0; i < duplicates.length(); i++){
......
......@@ -20,7 +20,8 @@ private:
QOpenGLShaderProgram *edgeShader;
QOpenGLShaderProgram *initEdgeComputeShaderProgram();
void precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &edgeIndices_base);
void precomputeTables(Mesh *mesh, QVector<QVector<unsigned int> > &edgeIndices_base,
QVector<unsigned int> &vertexIndices, QVector<unsigned int> &vertexIndicesOffsets);
void runShader(Mesh *mesh, QVector<QVector<unsigned int> > &edgeIndices);
QVector<unsigned int> fillVector(unsigned int a, unsigned int b, unsigned int c,unsigned int d);
......
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