Skip to content

Commit

Permalink
Reorder TestTriangleAgainstAabb2 dimension checks to very slightly im…
Browse files Browse the repository at this point in the history
…prove performance
  • Loading branch information
ZealanL committed May 11, 2024
1 parent de24e48 commit 67e20ee
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions libsrc/bullet3-3.24/LinearMath/btAabbUtil2.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ SIMD_FORCE_INLINE bool TestTriangleAgainstAabb2(const btVector3* vertices,
const btVector3& p2 = vertices[1];
const btVector3& p3 = vertices[2];

if (btMin(btMin(p1[0], p2[0]), p3[0]) > aabbMax[0]) return false;
if (btMax(btMax(p1[0], p2[0]), p3[0]) < aabbMin[0]) return false;
// First check Z, then X, then Y
constexpr int INDEX_ORDER[] = { 2, 0, 1 };

if (btMin(btMin(p1[2], p2[2]), p3[2]) > aabbMax[2]) return false;
if (btMax(btMax(p1[2], p2[2]), p3[2]) < aabbMin[2]) return false;

if (btMin(btMin(p1[1], p2[1]), p3[1]) > aabbMax[1]) return false;
if (btMax(btMax(p1[1], p2[1]), p3[1]) < aabbMin[1]) return false;
for (int i : INDEX_ORDER) {
if (btMin(btMin(p1[i], p2[i]), p3[i]) > aabbMax[i]) return false;
if (btMax(btMax(p1[i], p2[i]), p3[i]) < aabbMin[i]) return false;
}

return true;
}

Expand Down

0 comments on commit 67e20ee

Please sign in to comment.