Commit 5054d495 by Philipp Adolf

temp

parent 5e6a5286
...@@ -271,18 +271,14 @@ void Subdivision::buildNeighborsMap(QVector<Vertex> &vb, QVector<Triangle> &tria ...@@ -271,18 +271,14 @@ void Subdivision::buildNeighborsMap(QVector<Vertex> &vb, QVector<Triangle> &tria
subTimer.restart(); subTimer.restart();
f->glBindBuffer(GL_SHADER_STORAGE_BUFFER, output_handle); f->glBindBuffer(GL_SHADER_STORAGE_BUFFER, output_handle);
GLint *out_ptr = (GLint *) f->glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY); GLint *out_ptr = (GLint *) f->glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_READ_ONLY);
bool valid = true; for (int i = 0; i < triangles.length(); i++) {
for (int i = 0; i < 3 * triangles.length(); i++) { Triangle::Neighbors ns;
if (out_ptr[i] < 0 || out_ptr[i] >= triangles.length()) {
qCWarning(log_subdiv) << "Invalid neighbor:" << i << out_ptr[i];
valid = false;
}
}
if (valid) {
for (int i = 0; i < triangles.length(); i++) {
Triangle::Neighbors ns;
GLint other = out_ptr[3 * i + 0]; GLint other = out_ptr[3 * i + 0];
assert(other < triangles.length());
if (other < 0) {
ns.uv.triangle = NULL;
} else {
ns.uv.triangle = &(triangles[other]); ns.uv.triangle = &(triangles[other]);
if (out_ptr[3 * other + 0] == i) { if (out_ptr[3 * other + 0] == i) {
ns.uv.edge.name = Triangle::Edge::Name::uv; ns.uv.edge.name = Triangle::Edge::Name::uv;
...@@ -300,8 +296,13 @@ void Subdivision::buildNeighborsMap(QVector<Vertex> &vb, QVector<Triangle> &tria ...@@ -300,8 +296,13 @@ void Subdivision::buildNeighborsMap(QVector<Vertex> &vb, QVector<Triangle> &tria
ns.uv.edge.b = ns.uv.triangle->u_idx(); ns.uv.edge.b = ns.uv.triangle->u_idx();
ns.uv.edge.c = ns.uv.triangle->v_idx(); ns.uv.edge.c = ns.uv.triangle->v_idx();
} }
}
other = out_ptr[3 * i + 1]; other = out_ptr[3 * i + 1];
assert(other < triangles.length());
if (other < 0) {
ns.vw.triangle = NULL;
} else {
ns.vw.triangle = &(triangles[other]); ns.vw.triangle = &(triangles[other]);
if (out_ptr[3 * other + 0] == i) { if (out_ptr[3 * other + 0] == i) {
ns.vw.edge.name = Triangle::Edge::Name::uv; ns.vw.edge.name = Triangle::Edge::Name::uv;
...@@ -319,8 +320,13 @@ void Subdivision::buildNeighborsMap(QVector<Vertex> &vb, QVector<Triangle> &tria ...@@ -319,8 +320,13 @@ void Subdivision::buildNeighborsMap(QVector<Vertex> &vb, QVector<Triangle> &tria
ns.vw.edge.b = ns.vw.triangle->u_idx(); ns.vw.edge.b = ns.vw.triangle->u_idx();
ns.vw.edge.c = ns.vw.triangle->v_idx(); ns.vw.edge.c = ns.vw.triangle->v_idx();
} }
}
other = out_ptr[3 * i + 2]; other = out_ptr[3 * i + 2];
assert(other < triangles.length());
if (other < 0) {
ns.wu.triangle = NULL;
} else {
ns.wu.triangle = &(triangles[other]); ns.wu.triangle = &(triangles[other]);
if (out_ptr[3 * other + 0] == i) { if (out_ptr[3 * other + 0] == i) {
ns.wu.edge.name = Triangle::Edge::Name::uv; ns.wu.edge.name = Triangle::Edge::Name::uv;
...@@ -338,9 +344,9 @@ void Subdivision::buildNeighborsMap(QVector<Vertex> &vb, QVector<Triangle> &tria ...@@ -338,9 +344,9 @@ void Subdivision::buildNeighborsMap(QVector<Vertex> &vb, QVector<Triangle> &tria
ns.wu.edge.b = ns.wu.triangle->u_idx(); ns.wu.edge.b = ns.wu.triangle->u_idx();
ns.wu.edge.c = ns.wu.triangle->v_idx(); ns.wu.edge.c = ns.wu.triangle->v_idx();
} }
neighbors.insert(triangles[i], ns);
} }
neighbors.insert(triangles[i], ns);
} }
f->glUnmapBuffer(GL_SHADER_STORAGE_BUFFER); f->glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
......
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