Commit 067556e5 by Philipp Adolf

Merge master into patchRender (using imerge)

parents 21f7a420 a7ab78ce
...@@ -477,7 +477,41 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib) ...@@ -477,7 +477,41 @@ QVector<unsigned int> Subdivision::getPatchIndexBuffer(QVector<unsigned int> ib)
} }
return pib; return pib;
}
/*
* TODO: test code, use it
*
* Would probably be a good idea to store both regular and irregular patches.
*/
void Subdivision::extractPatches(QVector<unsigned int> index_buffer, QVector<Vertex> vertex_buffer, QVector<Subdivision::Patch> &patches){
patches.clear();
for (unsigned int i = 0; i < index_buffer.length()-2; i += 3){
Vertex vx = vertex_buffer[index_buffer[i]];
Vertex vy = vertex_buffer[index_buffer[i+1]];
Vertex vz = vertex_buffer[index_buffer[i+2]];
int countx = 0;
int county = 0;
int countz = 0;
for(unsigned int j = 0; j < index_buffer.length(); j++){
if (j != i && j != i+1 && j != i+2){
if (vx.samePos(vertex_buffer[index_buffer[j]])){
countx++;
}
if (vy.samePos(vertex_buffer[index_buffer[j]])){
county++;
}
if (vz.samePos(vertex_buffer[index_buffer[j]])){
countz++;
}
}
}
if (countx != 5 || county != 5 || countz != 5){
//triangle is irregular
}
}
} }
bool Subdivision::matchAndCompleteTriangle(unsigned int sx, unsigned int sy, unsigned int sz, unsigned int tx, unsigned int ty, unsigned int &tz){ bool Subdivision::matchAndCompleteTriangle(unsigned int sx, unsigned int sy, unsigned int sz, unsigned int tx, unsigned int ty, unsigned int &tz){
......
...@@ -41,12 +41,19 @@ private: ...@@ -41,12 +41,19 @@ private:
QVector<Vertex> vertex_buffer; QVector<Vertex> vertex_buffer;
}; };
struct Patch
{
QVector<unsigned int> index_buffer;
bool is_regular;
};
QOpenGLFunctions_4_3_Core *f; QOpenGLFunctions_4_3_Core *f;
QOpenGLShaderProgram *edgeShader; QOpenGLShaderProgram *edgeShader;
QOpenGLShaderProgram *vertexShader; QOpenGLShaderProgram *vertexShader;
QOpenGLShaderProgram *initComputeShaderProgram(QString &source); QOpenGLShaderProgram *initComputeShaderProgram(QString &source);
Tables precomputeTables(Input input); Tables precomputeTables(Input input);
void extractPatches(QVector<unsigned int> index_buffer, QVector<Vertex> vertex_buffer, QVector<Patch> &patches);
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);
void runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indices_handle, GLuint output_handle, GLuint offset); void runEdgeShader(GLuint size, GLuint vb_handle, GLuint edge_indices_handle, GLuint output_handle, GLuint offset);
......
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