summaryrefslogtreecommitdiffstats
path: root/thirdparty/meshoptimizer/vcacheoptimizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/meshoptimizer/vcacheoptimizer.cpp')
-rw-r--r--thirdparty/meshoptimizer/vcacheoptimizer.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/thirdparty/meshoptimizer/vcacheoptimizer.cpp b/thirdparty/meshoptimizer/vcacheoptimizer.cpp
index ce8fd3a887..d4b08ba340 100644
--- a/thirdparty/meshoptimizer/vcacheoptimizer.cpp
+++ b/thirdparty/meshoptimizer/vcacheoptimizer.cpp
@@ -221,9 +221,9 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
triangle_scores[i] = vertex_scores[a] + vertex_scores[b] + vertex_scores[c];
}
- unsigned int cache_holder[2 * (kCacheSizeMax + 3)];
+ unsigned int cache_holder[2 * (kCacheSizeMax + 4)];
unsigned int* cache = cache_holder;
- unsigned int* cache_new = cache_holder + kCacheSizeMax + 3;
+ unsigned int* cache_new = cache_holder + kCacheSizeMax + 4;
size_t cache_count = 0;
unsigned int current_triangle = 0;
@@ -260,10 +260,8 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
{
unsigned int index = cache[i];
- if (index != a && index != b && index != c)
- {
- cache_new[cache_write++] = index;
- }
+ cache_new[cache_write] = index;
+ cache_write += (index != a && index != b && index != c);
}
unsigned int* cache_temp = cache;
@@ -305,6 +303,10 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
{
unsigned int index = cache[i];
+ // no need to update scores if we are never going to use this vertex
+ if (adjacency.counts[index] == 0)
+ continue;
+
int cache_position = i >= cache_size ? -1 : int(i);
// update vertex score
@@ -325,11 +327,8 @@ void meshopt_optimizeVertexCacheTable(unsigned int* destination, const unsigned
float tri_score = triangle_scores[tri] + score_diff;
assert(tri_score > 0);
- if (best_score < tri_score)
- {
- best_triangle = tri;
- best_score = tri_score;
- }
+ best_triangle = best_score < tri_score ? tri : best_triangle;
+ best_score = best_score < tri_score ? tri_score : best_score;
triangle_scores[tri] = tri_score;
}