From 5f652cd660c1f6522dcc5919a6ac6948fffc6031 Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Tue, 6 Dec 2011 11:38:39 +0000 Subject: [PATCH] Fix for Issue 187 --- Recast/Source/RecastContour.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Recast/Source/RecastContour.cpp b/Recast/Source/RecastContour.cpp index 078c464..79c7168 100644 --- a/Recast/Source/RecastContour.cpp +++ b/Recast/Source/RecastContour.cpp @@ -420,15 +420,13 @@ static void simplifyContour(rcIntArray& points, rcIntArray& simplified, // Round based on the segments in lexilogical order so that the // max tesselation is consistent regardles in which direction // segments are traversed. - if (bx > ax || (bx == ax && bz > az)) + const int n = bi < ai ? (bi+pn - ai) : (bi - ai); + if (n > 1) { - const int n = bi < ai ? (bi+pn - ai) : (bi - ai); - maxi = (ai + n/2) % pn; - } - else - { - const int n = bi < ai ? (bi+pn - ai) : (bi - ai); - maxi = (ai + (n+1)/2) % pn; + if (bx > ax || (bx == ax && bz > az)) + maxi = (ai + n/2) % pn; + else + maxi = (ai + (n+1)/2) % pn; } } }