From 79eb3a1fdd97c2df8dd0d42b8a214dece93b38de Mon Sep 17 00:00:00 2001 From: JaeYoung Kim Date: Wed, 18 May 2016 19:13:28 +0900 Subject: [PATCH 1/2] bugfix - different from original c++ code & was not able to pass unit test --- Source/SharpNav/Heightfield.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/SharpNav/Heightfield.cs b/Source/SharpNav/Heightfield.cs index f56f04da..3f62c741 100644 --- a/Source/SharpNav/Heightfield.cs +++ b/Source/SharpNav/Heightfield.cs @@ -61,9 +61,9 @@ public Heightfield(BBox3 b, float cellSize, float cellHeight) this.bounds = b; //make sure the bbox contains all the possible voxels. - width = (int)Math.Ceiling((b.Max.X - b.Min.X) / cellSize); - height = (int)Math.Ceiling((b.Max.Y - b.Min.Y) / cellHeight); - length = (int)Math.Ceiling((b.Max.Z - b.Min.Z) / cellSize); + width = (int)Math.Round((b.Max.X - b.Min.X) / cellSize); + height = (int)Math.Round((b.Max.Y - b.Min.Y) / cellHeight); + length = (int)Math.Round((b.Max.Z - b.Min.Z) / cellSize); bounds.Max.X = bounds.Min.X + width * cellSize; bounds.Max.Y = bounds.Min.Y + height * cellHeight; From 3284c5ffda4902867ccaccfb4fc88dba3c433267 Mon Sep 17 00:00:00 2001 From: JaeYoung Kim Date: Wed, 18 May 2016 19:19:01 +0900 Subject: [PATCH 2/2] bugfix - different from original c++ code / 'verts.Count' is mutable value while looping --- Source/SharpNav/PolyMeshDetail.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SharpNav/PolyMeshDetail.cs b/Source/SharpNav/PolyMeshDetail.cs index f62adf7f..9555e3cf 100644 --- a/Source/SharpNav/PolyMeshDetail.cs +++ b/Source/SharpNav/PolyMeshDetail.cs @@ -639,7 +639,7 @@ private void BuildPolyDetail(Vector3[] polyMeshVerts, int numMeshVerts, float sa //tessellate outlines if (sampleDist > 0) { - for (int i = 0, j = verts.Count - 1; i < verts.Count; j = i++) + for (int i = 0, j = numMeshVerts - 1; i < numMeshVerts; j = i++) { Vector3 vi = verts[i]; Vector3 vj = verts[j];