From d9652b362e46a1d20b2fa3c1e23d626d6feb4f41 Mon Sep 17 00:00:00 2001 From: Kromster80 Date: Mon, 10 Nov 2014 15:08:03 +0300 Subject: [PATCH] Update RecastMeshDetail.cpp --- Recast/Source/RecastMeshDetail.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Recast/Source/RecastMeshDetail.cpp b/Recast/Source/RecastMeshDetail.cpp index 5cc2adf..2fe070b 100644 --- a/Recast/Source/RecastMeshDetail.cpp +++ b/Recast/Source/RecastMeshDetail.cpp @@ -507,15 +507,9 @@ static float polyMinExtent(const float* verts, const int nverts) return rcSqrt(minDist); } -inline int next(int i, int n) -{ - return (i+1) % n; -} - -inline int prev(int i, int n) -{ - return (i + n-1) % n; -} +// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv). +inline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; } +inline int next(int i, int n) { return i+1 < n ? i+1 : 0; } static void triangulateHull(const int nverts, const float* verts, const int nhull, const int* hull, rcIntArray& tris) {