Commit 40d7dd3a by Alisa Jung

helper method for finding and matching triangles. fixed some codependent indices…

helper method for finding and matching triangles. fixed some codependent indices in patch index buffer computation.
parent 307cb8a3
......@@ -417,46 +417,11 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib)
unsigned int j2 = ib[j+2];
//Dreieck angrenzend an Kante i3 i6
if (j0 == i3 && j2 == i6){
i2 = j1;
found36 = true;
}
if (j1 == i3 && j0 == i6){
i2 = j2;
found36 = true;
}
if (j2 == i3 && j1 == i6){
i2 == j0;
found36 = true;
}
found36 |= matchAndCompleteTriangle(j0,j1,j2,i6,i3,i2);
//Dreieck angrenzend an Kante i6 i7
if (j0 == i6 && j2 == i7){
i10 = j1;
found67 = true;
}
if (j1 == i6 && j0 == i7){
i10 = j2;
found67 = true;
}
if (j2 == i6 && j1 == i7){
i10 = j0;
found67 = true;
}
found67 |= matchAndCompleteTriangle(j0,j1,j2,i7,i6,i10);
//Dreieck angrenzend an Kante i7 i3
if (j0 == i7 && j2 == i3){
i4 = j1;
found73 = true;
}
if (j1 == i7 && j0 == i3){
i4 == j2;
found73 = true;
}
if (j2 == i7 && j1 == i3){
i4 = j0;
found73 = true;
}
found73 |= matchAndCompleteTriangle(j0,j1,j2,i3,i7,i4);
}
if (!(found36 && found67 && found73)){
......@@ -475,93 +440,18 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib)
unsigned int j2 = ib[j+2];
//find i0. //TODO assert triangle 031 \exists somewhere
if (j0 == i2 && j1 == i3){
i0 == j2;
found0 = true;
}
if (j1 == i2 && j2 == i3){
i0 = j0;
found0 = true;
}
if (j2 == i2 && j0 == i3){
i0 = j1;
found0 = true;
}
//find i1
if (j0 == i3 && j1 == i4){
i1 = j2;
found1 = true;
}
if (j1 == i3 && j2 == i4){
i1 = j0;
found1 = true;
}
if (j2 == i3 && j0 == i4){
i1 = j1;
found1 = true;
}
found0 |= matchAndCompleteTriangle(j0,j1,j2,i2,i3,i0);
found1 |= matchAndCompleteTriangle(j0,j1,j2,i3,i4,i1);
//TODO maybe assert that triangle i0 i3 i1 actually \exists.
//find i5.
if(j0 == i6 && j1 == i2){
i5 = j2;
found5 = true;
}
if (j1 == i6 && j2 == i2){
i5 = j0;
found5 = true;
}
if (j2 == i6 && j0 == i2){
i5 = j1;
found5 = true;
}
//find i9.
if (j0 == i10 && j1 == i6){
i9 = j2;
found9 = true;
}
if (j1 == i10 && j2 == i6){
i9 = j0;
found9 = true;
}
if (j2 == i10 && j0 == i6){
i9 = j1;
found9 = true;
}
found5 |= matchAndCompleteTriangle(j0,j1,j2,i6,i2,i5);
found9 |= matchAndCompleteTriangle(j0,j1,j2,i10,i6,i9);
//todo assert that triangle i5 i9 i6
//find i8
if (j0 == i4 && j1 == i7){
i8 = j2;
found8 = true;
}
if (j1 == i4 && j2 == i7){
i8 = j0;
found8 = true;
}
if (j2 == i4 && j0 == i7){
i8 = j1;
found8 = true;
}
//find i11
if (j0 == i7 && j1 == i10){
i11 = j2;
found11 = true;
}
if (j1 == i7 && j2 == i10){
i11 = j0;
found11 = true;
}
if (j2 == i7 && j0 == i10){
i11 = j1;
found11 = true;
}
found8 |= matchAndCompleteTriangle(j0,j1,j2,i4,i7,i8);
found11 |= matchAndCompleteTriangle(j0,j1,j2,i7,i10,i11);
}
if (!(found0 && found1 && found5 && found9 && found8 && found11)){
qWarning()<<"Couldnt find some neighbour at i= "<<i;
......@@ -589,6 +479,22 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib)
}
bool Subdivision::matchAndCompleteTriangle(unsigned int sx, unsigned int sy, unsigned int sz, unsigned int tx, unsigned int ty, unsigned int &tz){
if (sx == tx && sy == ty){
tz = sz;
return true;
}
if (sy == tx && sz == ty){
tz = sx;
return true;
}
if (sz == tx && sx == ty){
tz = sy;
return true;
}
return false;
}
Subdivision::Result Subdivision::runShader(Input input, Tables &tables) {
qDebug()<<"Running compute shader";
......
......@@ -53,6 +53,17 @@ private:
//Geht davon aus, dass jeder 3D-Punkt nur einmal im Vertex-Buffer vorkommt!
QVector<unsigned int> getPatchIndexBuffer(QVector<unsigned int> ib);
/**
* @brief matchAndCompleteTriangle if tx ty matches sxsy, sysz or szsy, fill tz with third source vertex index.
* @param sx source triangle: first vertex
* @param sy source triangle: second vertex
* @param sz source triangle: third vertex
* @param tx target triangle: first known vertex
* @param ty target triangle: second known vertex
* @param tz target triangle: unknown vertex.
* @return true if triangles could be matched and tz was filled.
*/
bool matchAndCompleteTriangle(unsigned int sx, unsigned int sy, unsigned int sz, unsigned int tx, unsigned int ty, unsigned int& tz);
};
#endif
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