Commit f804bd56 by Philipp Adolf

Add updateSharpEdges

parent e6ccfe75
......@@ -136,6 +136,8 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
* erst die Vertex-points (in der selben Reihenfolge wie im ursprünglichen Vertex-Buffer) und dann die Edgepoints kommen.
*
* Einträge in neuem Vertex-buffer: Verschobene Knoten aus altem Vertex-Buffer :: edge-vertices erstellt aus edgeIndices_base.
*
* sharpEdges: Vorher leer, wird sonst geleert, wird gefüllt mit neuen sharp edges, alte sollten im Input stehen.
*/
Subdivision::Tables Subdivision::precomputeTables(Input input) {
Tables tables;
......@@ -184,6 +186,9 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
updateIndexBuffer(tables.extra_triangles, modified_vertices);
qCDebug(log_timing) << "updateIndexBuffer:" << formatTimeMeasurement(subTimer.elapsed());
subTimer.restart();
updateSharpEdges(input.sharp_edges,tables.sharp_edges,modified_vertices,old_edge_to_new_vertex);
qCDebug(log_subdiv) << "Precompute Tables Done";
return tables;
}
......@@ -711,6 +716,28 @@ void Subdivision::updateIndexBuffer(QVector<unsigned int> &index_buffer, QMap<un
}
}
void Subdivision::updateSharpEdges(const QMap<Edge,unsigned int> &sharp_edges_old,
QMap<Edge,unsigned int> &sharp_edges_new,
const QMap<unsigned int, unsigned int>& old_vertex_to_new_vertex,
const QMap<Edge,unsigned int> &old_edge_to_new_vertex){
sharp_edges_new.clear();
for (Edge e : sharp_edges_old.keys()){
unsigned int sharpness_old = sharp_edges_old.value(e);
if (sharpness_old > 1){
unsigned int u_old = e.a;
unsigned int v_old = e.b;
unsigned int u_new = old_vertex_to_new_vertex[u_old];
unsigned int v_new = old_vertex_to_new_vertex[v_new];
unsigned int center = old_edge_to_new_vertex[Edge(u_old,v_old)];
unsigned int sharpness_new = sharpness_old - 1;
sharp_edges_new.insert(Edge(u_new,center),sharpness_new);
sharp_edges_new.insert(Edge(center, v_new),sharpness_new);
//TODO find regular darf sharpe sachen nicht als regular sehen
}
}
}
void Subdivision::splitRegular(Mesh *mesh) {
QTime totalTimer;
totalTimer.start();
......
......@@ -75,6 +75,10 @@ private:
QVector<unsigned int> getAllVertexIndices(const QVector<Vertex> &vb, const QVector<Triangle> &triangles);
bool removeVertexIndex(const QVector<Vertex> &vb, QVector<unsigned int> &vertices, const Vertex &vertex);
void updateIndexBuffer(QVector<unsigned int> &index_buffer, QMap<unsigned int, unsigned int> map);
void updateSharpEdges(const QMap<Edge,unsigned int> &sharp_edges_old,
QMap<Edge,unsigned int> &sharp_edges_new,
const QMap<unsigned int, unsigned int>& old_vertex_to_new_vertex,
const QMap<Edge,unsigned int> &old_edge_to_new_vertex);
void findRegular(QVector<Triangle> triangles, QMap<Triangle, Triangle::Neighbors> neighbors, QVector<Triangle> &regular, QVector<Triangle> &irregular);
Result runShader(Input input, Tables &tables);
void runCopyShader(GLuint size, GLuint vb_in, GLuint vb_out);
......
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