Commit 39d315af by Alisa Jung

getPatchIndexBuffer fix: check if vertices have same position (not necessarily same index)

Vertex == now only compares position Conflicts: QTProject/subdivision.h
parent 87d5c28e
......@@ -32,7 +32,7 @@ private:
QVector<GLuint> vertex_indices;
QVector<GLuint> vertex_offsets;
QVector<GLuint> index_buffer;
QVector<GLuint> index_regular;
QVector<GLuint> patch_index_regular;
};
struct Result
......@@ -60,21 +60,41 @@ private:
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);
//Geht davon aus, dass jeder 3D-Punkt nur einmal im Vertex-Buffer vorkommt!
QVector<unsigned int> getPatchIndexBuffer(QVector<unsigned int> ib);
QVector<unsigned int> getTriangles(QVector<unsigned int> ib);
QVector<unsigned int> getPatchIndexBuffer(QVector<unsigned int> ib_regular, QVector<unsigned int> ib_irregular, QVector<Vertex> vb);
/**
* @brief matchAndCompleteTriangleIndices if Indices tx ty matches sxsy, sysz or szsy, fill tz with third source vertex index.
* @param sx source triangle: first vertex index
* @param sy source triangle: second vertex index
* @param sz source triangle: third vertex index
* @param tx target triangle: first known vertex index
* @param ty target triangle: second known vertex index
* @param tz target triangle: unknown vertex index.
* @return true if triangles could be matched and tz was filled.
* Only use this method if you are absolutely sure that each vertex position appears ONLY ONCE in the vertex buffer!!
* No duplicate vertices with different normals or crap like that!
*/
bool matchAndCompleteTriangleIndices(unsigned int sx, unsigned int sy, unsigned int sz, unsigned int tx, unsigned int ty, unsigned int& tz);
//same as matchandcomplete. doesn't rely on only one index per vertex location
//needs indices to fill tz
/**
* @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.
* @brief matchAndCompleteTriangle if vertices at indices tx ty matches vertices at indices sxsy, sysz or szsy,
* fill tz with third source vertex index.
* @param sx source triangle: first vertex index
* @param sy source triangle: second vertex index
* @param sz source triangle: third vertex index
* @param tx target triangle: first known vertex index
* @param ty target triangle: second known vertex index
* @param tz target triangle: unknown vertex index.
* @param vb Vertex Buffer. This method compares the actual positions of the vertices
* @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);
bool matchAndCompleteTriangle(unsigned int sx, unsigned int sy, unsigned int sz, unsigned int tx, unsigned int ty, unsigned int &tz, QVector<Vertex> vb);
};
#endif
......@@ -21,6 +21,12 @@ struct Vertex
Vertex(const QVector3D& pos, const QVector3D& normal, const QVector2D& tex);
bool samePos(const Vertex& other) const;
bool operator==(const Vertex& other) const
{
return samePos(other);
}
};
#pragma pack(pop)
......
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