From 38d94b08bf0f784ccec5b082f46d87852c114e34 Mon Sep 17 00:00:00 2001 From: ikpil Date: Mon, 26 Jun 2023 22:50:24 +0900 Subject: [PATCH] test code --- src/DotRecast.Core/SegmentVert.cs | 27 +++------ .../GetPolyWallSegmentsTest.cs | 58 ++++++++++--------- 2 files changed, 41 insertions(+), 44 deletions(-) diff --git a/src/DotRecast.Core/SegmentVert.cs b/src/DotRecast.Core/SegmentVert.cs index 4bb6ff7..0e04c4e 100644 --- a/src/DotRecast.Core/SegmentVert.cs +++ b/src/DotRecast.Core/SegmentVert.cs @@ -1,29 +1,20 @@ -using System; - -namespace DotRecast.Core +namespace DotRecast.Core { public struct SegmentVert { public RcVec3f vmin; public RcVec3f vmax; - public float this[int index] + public SegmentVert(float v0, float v1, float v2, float v3, float v4, float v5) { - get => GetElement(index); + vmin.x = v0; + vmin.y = v1; + vmin.z = v2; + + vmax.x = v3; + vmax.y = v4; + vmax.z = v5; } - public float GetElement(int index) - { - switch (index) - { - case 0: return vmin.x; - case 1: return vmin.y; - case 2: return vmin.z; - case 3: return vmax.x; - case 4: return vmax.y; - case 5: return vmax.z; - default: throw new IndexOutOfRangeException($"{index}"); - } - } } } \ No newline at end of file diff --git a/test/DotRecast.Detour.Test/GetPolyWallSegmentsTest.cs b/test/DotRecast.Detour.Test/GetPolyWallSegmentsTest.cs index a7b2004..dd50aae 100644 --- a/test/DotRecast.Detour.Test/GetPolyWallSegmentsTest.cs +++ b/test/DotRecast.Detour.Test/GetPolyWallSegmentsTest.cs @@ -29,40 +29,44 @@ public class GetPolyWallSegmentsTest : AbstractDetourTest { new[] { - 22.084785f, 10.197294f, -48.341274f, 22.684784f, 10.197294f, -44.141273f, 22.684784f, 10.197294f, - -44.141273f, 23.884785f, 10.197294f, -48.041275f, 23.884785f, 10.197294f, -48.041275f, 22.084785f, - 10.197294f, -48.341274f + 22.084785f, 10.197294f, -48.341274f, 22.684784f, 10.197294f, -44.141273f, + 22.684784f, 10.197294f, -44.141273f, 23.884785f, 10.197294f, -48.041275f, + 23.884785f, 10.197294f, -48.041275f, 22.084785f, 10.197294f, -48.341274f, }, new[] { - 27.784786f, 10.197294f, 4.158730f, 28.384785f, 10.197294f, 2.358727f, 28.384785f, 10.197294f, 2.358727f, - 28.384785f, 10.197294f, -2.141273f, 28.384785f, 10.197294f, -2.141273f, 27.784786f, 10.197294f, - -2.741272f, 27.784786f, 10.197294f, -2.741272f, 19.684784f, 10.197294f, -4.241272f, 19.684784f, - 10.197294f, -4.241272f, 19.684784f, 10.197294f, 4.158730f, 19.684784f, 10.197294f, 4.158730f, - 27.784786f, 10.197294f, 4.158730f + 27.784786f, 10.197294f, 4.158730f, 28.384785f, 10.197294f, 2.358727f, + 28.384785f, 10.197294f, 2.358727f, 28.384785f, 10.197294f, -2.141273f, + 28.384785f, 10.197294f, -2.141273f, 27.784786f, 10.197294f, -2.741272f, + 27.784786f, 10.197294f, -2.741272f, 19.684784f, 10.197294f, -4.241272f, + 19.684784f, 10.197294f, -4.241272f, 19.684784f, 10.197294f, 4.158730f, + 19.684784f, 10.197294f, 4.158730f, 27.784786f, 10.197294f, 4.158730f, }, new[] { - 22.384785f, 14.997294f, -71.741272f, 19.084785f, 16.597294f, -74.741272f, 19.084785f, 16.597294f, - -74.741272f, 18.184784f, 15.997294f, -73.541275f, 18.184784f, 15.997294f, -73.541275f, 17.884785f, - 14.997294f, -72.341278f, 17.884785f, 14.997294f, -72.341278f, 17.584785f, 14.997294f, -70.841278f, - 17.584785f, 14.997294f, -70.841278f, 22.084785f, 14.997294f, -70.541275f, 22.084785f, 14.997294f, - -70.541275f, 22.384785f, 14.997294f, -71.741272f + 22.384785f, 14.997294f, -71.741272f, 19.084785f, 16.597294f, -74.741272f, + 19.084785f, 16.597294f, -74.741272f, 18.184784f, 15.997294f, -73.541275f, + 18.184784f, 15.997294f, -73.541275f, 17.884785f, 14.997294f, -72.341278f, + 17.884785f, 14.997294f, -72.341278f, 17.584785f, 14.997294f, -70.841278f, + 17.584785f, 14.997294f, -70.841278f, 22.084785f, 14.997294f, -70.541275f, + 22.084785f, 14.997294f, -70.541275f, 22.384785f, 14.997294f, -71.741272f, }, new[] { - 4.684784f, 10.197294f, -6.941269f, 1.984785f, 10.197294f, -8.441269f, 1.984785f, 10.197294f, -8.441269f, - -4.015217f, 10.197294f, -6.941269f, -4.015217f, 10.197294f, -6.941269f, -1.615215f, 10.197294f, - -1.541275f, -1.615215f, 10.197294f, -1.541275f, 1.384785f, 10.197294f, 1.458725f, 1.384785f, - 10.197294f, 1.458725f, 7.984783f, 10.197294f, -2.441269f, 7.984783f, 10.197294f, -2.441269f, - 4.684784f, 10.197294f, -6.941269f + 4.684784f, 10.197294f, -6.941269f, 1.984785f, 10.197294f, -8.441269f, + 1.984785f, 10.197294f, -8.441269f, -4.015217f, 10.197294f, -6.941269f, + -4.015217f, 10.197294f, -6.941269f, -1.615215f, 10.197294f, -1.541275f, + -1.615215f, 10.197294f, -1.541275f, 1.384785f, 10.197294f, 1.458725f, + 1.384785f, 10.197294f, 1.458725f, 7.984783f, 10.197294f, -2.441269f, + 7.984783f, 10.197294f, -2.441269f, 4.684784f, 10.197294f, -6.941269f, }, new[] { - -22.315216f, 6.597294f, -17.141273f, -23.815216f, 5.397294f, -13.841270f, -23.815216f, 5.397294f, - -13.841270f, -24.115217f, 4.997294f, -12.041275f, -24.115217f, 4.997294f, -12.041275f, -22.315216f, - 4.997294f, -11.441269f, -22.315216f, 4.997294f, -11.441269f, -17.815216f, 5.197294f, -11.441269f, - -17.815216f, 5.197294f, -11.441269f, -22.315216f, 6.597294f, -17.141273f + -22.315216f, 6.597294f, -17.141273f, -23.815216f, 5.397294f, -13.841270f, + -23.815216f, 5.397294f, -13.841270f, -24.115217f, 4.997294f, -12.041275f, + -24.115217f, 4.997294f, -12.041275f, -22.315216f, 4.997294f, -11.441269f, + -22.315216f, 4.997294f, -11.441269f, -17.815216f, 5.197294f, -11.441269f, + -17.815216f, 5.197294f, -11.441269f, -22.315216f, 6.597294f, -17.141273f, } }; @@ -89,10 +93,12 @@ public class GetPolyWallSegmentsTest : AbstractDetourTest Assert.That(segmentRefs.Count, Is.EqualTo(REFS[i].Length)); for (int v = 0; v < VERTICES[i].Length / 6; v++) { - for (int n = 0; n < 6; n++) - { - Assert.That(segmentVerts[v][n], Is.EqualTo(VERTICES[i][v * 6 + n]).Within(0.001f)); - } + Assert.That(segmentVerts[v].vmin.x, Is.EqualTo(VERTICES[i][v * 6 + 0]).Within(0.001f)); + Assert.That(segmentVerts[v].vmin.y, Is.EqualTo(VERTICES[i][v * 6 + 1]).Within(0.001f)); + Assert.That(segmentVerts[v].vmin.z, Is.EqualTo(VERTICES[i][v * 6 + 2]).Within(0.001f)); + Assert.That(segmentVerts[v].vmax.x, Is.EqualTo(VERTICES[i][v * 6 + 3]).Within(0.001f)); + Assert.That(segmentVerts[v].vmax.y, Is.EqualTo(VERTICES[i][v * 6 + 4]).Within(0.001f)); + Assert.That(segmentVerts[v].vmax.z, Is.EqualTo(VERTICES[i][v * 6 + 5]).Within(0.001f)); } for (int v = 0; v < REFS[i].Length; v++)