diff --git a/src/DotRecast.Detour.Crowd/LocalBoundary.cs b/src/DotRecast.Detour.Crowd/LocalBoundary.cs index c51004b..2be0f46 100644 --- a/src/DotRecast.Detour.Crowd/LocalBoundary.cs +++ b/src/DotRecast.Detour.Crowd/LocalBoundary.cs @@ -120,9 +120,9 @@ namespace DotRecast.Detour.Crowd if (result.succeeded()) { GetPolyWallSegmentsResult gpws = result.result; - for (int k = 0; k < gpws.getSegmentRefs().Count; ++k) + for (int k = 0; k < gpws.countSegmentRefs(); ++k) { - SegmentVert s = gpws.getSegmentVerts()[k]; + SegmentVert s = gpws.getSegmentVert(k); // Skip too distant segments. Tuple distseg = distancePtSegSqr2D(pos, s, 0, 3); if (distseg.Item1 > sqr(collisionQueryRange)) diff --git a/src/DotRecast.Detour/GetPolyWallSegmentsResult.cs b/src/DotRecast.Detour/GetPolyWallSegmentsResult.cs index ba7e49d..701a50d 100644 --- a/src/DotRecast.Detour/GetPolyWallSegmentsResult.cs +++ b/src/DotRecast.Detour/GetPolyWallSegmentsResult.cs @@ -25,23 +25,34 @@ namespace DotRecast.Detour { public class GetPolyWallSegmentsResult { - private readonly List segmentVerts; - private readonly List segmentRefs; + private readonly List _segmentVerts; + private readonly List _segmentRefs; public GetPolyWallSegmentsResult(List segmentVerts, List segmentRefs) { - this.segmentVerts = segmentVerts; - this.segmentRefs = segmentRefs; + _segmentVerts = segmentVerts; + _segmentRefs = segmentRefs; } - public List getSegmentVerts() + public int countSegmentVerts() { - return segmentVerts; + return _segmentVerts.Count; + } + + public int countSegmentRefs() + { + return _segmentRefs.Count; } - public List getSegmentRefs() + + public SegmentVert getSegmentVert(int idx) { - return segmentRefs; + return _segmentVerts[idx]; + } + + public long getSegmentRef(int idx) + { + return _segmentRefs[idx]; } } } \ No newline at end of file diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index abf32e3..c37caac 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -843,9 +843,9 @@ public class TestNavmeshTool : Tool { dd.begin(LINES, 2.0f); GetPolyWallSegmentsResult wallSegments = result.result; - for (int j = 0; j < wallSegments.getSegmentVerts().Count; ++j) + for (int j = 0; j < wallSegments.countSegmentVerts(); ++j) { - SegmentVert s = wallSegments.getSegmentVerts()[j]; + SegmentVert s = wallSegments.getSegmentVert(j); Vector3f s3 = Vector3f.Of(s[3], s[4], s[5]); // Skip too distant segments. Tuple distSqr = distancePtSegSqr2D(m_spos, s, 0, 3); @@ -860,7 +860,7 @@ public class TestNavmeshTool : Tool vNormalize(ref norm); Vector3f p1 = vMad(p0, norm, agentRadius * 0.5f); // Skip backfacing segments. - if (wallSegments.getSegmentRefs()[j] != 0) + if (wallSegments.getSegmentRef(j) != 0) { int col = duRGBA(255, 255, 255, 32); dd.vertex(s[0], s[1] + agentClimb, s[2], col); diff --git a/test/DotRecast.Detour.Test/GetPolyWallSegmentsTest.cs b/test/DotRecast.Detour.Test/GetPolyWallSegmentsTest.cs index 48282e4..ef882ad 100644 --- a/test/DotRecast.Detour.Test/GetPolyWallSegmentsTest.cs +++ b/test/DotRecast.Detour.Test/GetPolyWallSegmentsTest.cs @@ -80,19 +80,19 @@ public class GetPolyWallSegmentsTest : AbstractDetourTest { Result result = query.getPolyWallSegments(startRefs[i], true, filter); GetPolyWallSegmentsResult segments = result.result; - Assert.That(segments.getSegmentVerts().Count, Is.EqualTo(VERTICES[i].Length / 6)); - Assert.That(segments.getSegmentRefs().Count, Is.EqualTo(REFS[i].Length)); + Assert.That(segments.countSegmentVerts(), Is.EqualTo(VERTICES[i].Length / 6)); + Assert.That(segments.countSegmentRefs(), Is.EqualTo(REFS[i].Length)); for (int v = 0; v < VERTICES[i].Length / 6; v++) { for (int n = 0; n < 6; n++) { - Assert.That(segments.getSegmentVerts()[v][n], Is.EqualTo(VERTICES[i][v * 6 + n]).Within(0.001f)); + Assert.That(segments.getSegmentVert(v)[n], Is.EqualTo(VERTICES[i][v * 6 + n]).Within(0.001f)); } } for (int v = 0; v < REFS[i].Length; v++) { - Assert.That(segments.getSegmentRefs()[v], Is.EqualTo(REFS[i][v])); + Assert.That(segments.getSegmentRef(v), Is.EqualTo(REFS[i][v])); } } }