Commit 163766c2 by Philipp Adolf

Rename ibToTriangles to regularIbToTriangles

parent 38d1d37b
...@@ -95,9 +95,9 @@ void Subdivision::subdivide(Mesh *mesh, int level) { ...@@ -95,9 +95,9 @@ void Subdivision::subdivide(Mesh *mesh, int level) {
Result result = runShader(input, tables); Result result = runShader(input, tables);
QVector<Triangle> triangles; QVector<Triangle> triangles;
ibToTriangles(&result.vertex_buffer, tables.index_buffer, triangles); regularIbToTriangles(&result.vertex_buffer, tables.index_buffer, triangles);
QVector<Triangle> all_triangles; QVector<Triangle> all_triangles;
ibToTriangles(&result.vertex_buffer, tables.extra_triangles, all_triangles); regularIbToTriangles(&result.vertex_buffer, tables.extra_triangles, all_triangles);
all_triangles += triangles; all_triangles += triangles;
QMap<Triangle, Triangle::Neighbors> neighbors; QMap<Triangle, Triangle::Neighbors> neighbors;
...@@ -152,10 +152,10 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) { ...@@ -152,10 +152,10 @@ Subdivision::Tables Subdivision::precomputeTables(Input input) {
QTime subTimer; QTime subTimer;
subTimer.start(); subTimer.start();
QVector<Triangle> triangles; QVector<Triangle> triangles;
ibToTriangles(&vb, ib, triangles); regularIbToTriangles(&vb, ib, triangles);
QVector<Triangle> triangles_regular; QVector<Triangle> triangles_regular;
ibToTriangles(&vb, ib_regular, triangles_regular); regularIbToTriangles(&vb, ib_regular, triangles_regular);
qCDebug(log_timing) << "building Triangles:" << formatTimeMeasurement(subTimer.elapsed()); qCDebug(log_timing) << "building Triangles:" << formatTimeMeasurement(subTimer.elapsed());
...@@ -718,9 +718,11 @@ void Subdivision::splitRegular(Mesh *mesh) { ...@@ -718,9 +718,11 @@ void Subdivision::splitRegular(Mesh *mesh) {
Mesh::MeshEntry *current_mesh = mesh->getMeshEntry(first_mesh_index); Mesh::MeshEntry *current_mesh = mesh->getMeshEntry(first_mesh_index);
QVector<Triangle> all_triangles; QVector<Triangle> all_triangles;
ibToTriangles(&current_mesh->buffers[0]->vertices, current_mesh->buffers[0]->indices_irregular, all_triangles); regularIbToTriangles(&current_mesh->buffers[0]->vertices,
current_mesh->buffers[0]->indices_irregular,
all_triangles);
QVector<unsigned int> old_regular_ib = patchIBToTriangleIB(current_mesh->buffers[0]->indices_regular); QVector<unsigned int> old_regular_ib = patchIBToTriangleIB(current_mesh->buffers[0]->indices_regular);
ibToTriangles(&current_mesh->buffers[0]->vertices, old_regular_ib, all_triangles); regularIbToTriangles(&current_mesh->buffers[0]->vertices, old_regular_ib, all_triangles);
QMap<Triangle, Triangle::Neighbors> neighbors; QMap<Triangle, Triangle::Neighbors> neighbors;
buildNeighborsMap(current_mesh->buffers[0]->vertices, all_triangles, neighbors); buildNeighborsMap(current_mesh->buffers[0]->vertices, all_triangles, neighbors);
......
...@@ -208,12 +208,6 @@ Triangle::Edge::Name rotate_edge_name(Triangle::Edge::Name edge) { ...@@ -208,12 +208,6 @@ Triangle::Edge::Name rotate_edge_name(Triangle::Edge::Name edge) {
} }
} }
void ibToTriangles(QVector<Vertex> *vb, QVector<unsigned int> &ib, QVector<Triangle> &triangles) {
for (int i = 0; i < ib.length(); i+=3) {
triangles.push_back(Triangle(vb, ib[i], ib[i+1], ib[i+2]));
}
}
void Triangle::set_sharpness(Triangle::Edge::Name name, unsigned int value){ void Triangle::set_sharpness(Triangle::Edge::Name name, unsigned int value){
if (name == Edge::Name::uv){ if (name == Edge::Name::uv){
sharpness_uv = value; sharpness_uv = value;
...@@ -224,6 +218,16 @@ void Triangle::set_sharpness(Triangle::Edge::Name name, unsigned int value){ ...@@ -224,6 +218,16 @@ void Triangle::set_sharpness(Triangle::Edge::Name name, unsigned int value){
} }
} }
//basically the same as ibToTriangles without sharp edges
void regularIbToTriangles(const QVector<Vertex> *vb,
const QVector<unsigned int> &ib,
QVector<Triangle> &triangles) {
for (int i = 0; i < ib.length(); i+=3) {
triangles.push_back(Triangle(vb, ib[i], ib[i+1], ib[i+2]));
}
}
void trianglesToIB(const QVector<Triangle> &triangles, QVector<unsigned int> &ib) { void trianglesToIB(const QVector<Triangle> &triangles, QVector<unsigned int> &ib) {
ib.reserve(ib.length() + triangles.length() * 3); ib.reserve(ib.length() + triangles.length() * 3);
QVectorIterator<Triangle> it(triangles); QVectorIterator<Triangle> it(triangles);
......
...@@ -88,7 +88,7 @@ class Triangle { ...@@ -88,7 +88,7 @@ class Triangle {
}; };
Triangle::Edge::Name rotate_edge_name(Triangle::Edge::Name edge); Triangle::Edge::Name rotate_edge_name(Triangle::Edge::Name edge);
void ibToTriangles(QVector<Vertex> *vb, QVector<unsigned int> &ib, QVector<Triangle> &triangles); void regularIbToTriangles(const QVector<Vertex> *vb, const QVector<unsigned int> &ib, QVector<Triangle> &triangles);
void trianglesToIB(const QVector<Triangle> &triangles, QVector<unsigned int> &ib); void trianglesToIB(const QVector<Triangle> &triangles, QVector<unsigned int> &ib);
QDebug operator<<(QDebug d, const Triangle &triangle); QDebug operator<<(QDebug d, const Triangle &triangle);
......
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