Merge pull request #50 from Kromster80/Optimized-prev/next-comments

Optimized prev/next comments
This commit is contained in:
Mikko Mononen 2014-12-13 13:34:16 +02:00
commit 051d404da6
4 changed files with 6 additions and 10 deletions

View File

@ -1068,6 +1068,7 @@ static bool buildMeshAdjacency(dtTileCacheAlloc* alloc,
}
// 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; }

View File

@ -464,7 +464,7 @@ static int calcAreaOfPolygon2D(const int* verts, const int nverts)
}
// TODO: these are the same as in RecastMesh.cpp, consider using the same.
// 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; }

View File

@ -160,6 +160,7 @@ static unsigned short addVertex(unsigned short x, unsigned short y, unsigned sho
return (unsigned short)i;
}
// 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; }

View File

@ -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)
{