Refactor vertex fetch optimizer and add more assertions

We now range check indices in most algorithms and do some other sanity
checks. Also analyzers now correctly handle empty meshes.
This commit is contained in:
Arseny Kapoulkine
2017-07-09 20:15:03 -07:00
parent 1ce8128f8b
commit bec59756d4
5 changed files with 25 additions and 13 deletions
+5 -1
View File
@@ -22,6 +22,8 @@ static void buildAdjacency(Adjacency& adjacency, const T* indices, size_t index_
for (size_t i = 0; i < index_count; ++i)
{
assert(indices[i] < vertex_count);
adjacency.triangle_counts[indices[i]]++;
}
@@ -41,7 +43,9 @@ static void buildAdjacency(Adjacency& adjacency, const T* indices, size_t index_
std::vector<unsigned int> filled_triangle_counts(vertex_count, 0);
for (size_t i = 0; i < index_count / 3; ++i)
size_t face_count = index_count / 3;
for (size_t i = 0; i < face_count; ++i)
{
unsigned int a = indices[i * 3 + 0], b = indices[i * 3 + 1], c = indices[i * 3 + 2];