Skip to content
Permalink
Browse files

simplify: Optimize countTriangles by removing branches

We now use binary logic ops to determine whether the triangle is
degenerate or not, which makes countTriangles ~40% faster on some
workloads which makes the entire simplification process up to 4% faster.
  • Loading branch information...
zeux committed Feb 17, 2019
1 parent b4d4978 commit 99ab49af6706daf9716c0f1e2d1a1d99fdf12d81
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/simplifier.cpp
@@ -922,7 +922,7 @@ static size_t countTriangles(const unsigned int* vertex_ids, const unsigned int*
unsigned int id1 = vertex_ids[indices[i + 1]];
unsigned int id2 = vertex_ids[indices[i + 2]];

result += id0 != id1 && id0 != id2 && id1 != id2;
result += (id0 != id1) & (id0 != id2) & (id1 != id2);
}

return result;

0 comments on commit 99ab49a

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.