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; 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];