DotRecastNetSim/test/DotRecast.Detour.Test/MoveAlongSurfaceTest.cs

92 lines
3.8 KiB
C#
Raw Normal View History

2023-03-14 08:02:43 +03:00
/*
recast4j Copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
2023-03-29 18:59:00 +03:00
using DotRecast.Core;
2023-04-23 08:13:10 +03:00
using DotRecast.Detour.QueryResults;
2023-03-14 08:02:43 +03:00
using NUnit.Framework;
namespace DotRecast.Detour.Test;
2023-04-25 17:22:44 +03:00
[Parallelizable]
2023-03-16 19:48:49 +03:00
public class MoveAlongSurfaceTest : AbstractDetourTest
{
private static readonly long[][] VISITED =
{
new[]
{
281474976710696L, 281474976710695L, 281474976710694L, 281474976710703L, 281474976710706L,
281474976710705L, 281474976710702L, 281474976710701L, 281474976710714L, 281474976710713L,
281474976710712L, 281474976710727L, 281474976710730L, 281474976710717L, 281474976710721L
},
new[]
{
281474976710773L, 281474976710772L, 281474976710768L, 281474976710754L, 281474976710755L,
281474976710753L
},
new[]
{
281474976710680L, 281474976710684L, 281474976710688L, 281474976710687L, 281474976710686L,
281474976710697L, 281474976710695L, 281474976710694L, 281474976710703L, 281474976710706L,
281474976710705L, 281474976710702L, 281474976710701L, 281474976710714L, 281474976710713L,
281474976710712L, 281474976710727L, 281474976710730L, 281474976710717L, 281474976710721L,
281474976710718L
},
new[] { 281474976710753L, 281474976710748L, 281474976710752L, 281474976710731L },
new[]
{
281474976710733L, 281474976710736L, 281474976710738L, 281474976710737L, 281474976710728L,
281474976710724L, 281474976710717L, 281474976710729L, 281474976710731L, 281474976710752L,
281474976710748L, 281474976710753L, 281474976710755L, 281474976710754L, 281474976710768L,
281474976710772L
}
};
2023-03-14 08:02:43 +03:00
2023-03-16 19:48:49 +03:00
private static readonly float[][] POSITION =
{
new[] { 6.457663f, 10.197294f, -18.334061f },
new[] { -1.433933f, 10.197294f, -1.359993f },
new[] { 12.184784f, 9.997294f, -18.941269f },
new[] { 0.863553f, 10.197294f, -10.310320f },
new[] { 18.784092f, 10.197294f, 3.054368f }
};
2023-03-14 08:02:43 +03:00
[Test]
2023-03-16 19:48:49 +03:00
public void testMoveAlongSurface()
{
2023-03-14 08:02:43 +03:00
QueryFilter filter = new DefaultQueryFilter();
2023-03-16 19:48:49 +03:00
for (int i = 0; i < startRefs.Length; i++)
{
2023-03-14 08:02:43 +03:00
long startRef = startRefs[i];
2023-03-29 18:59:00 +03:00
Vector3f startPos = startPoss[i];
Vector3f endPos = endPoss[i];
2023-03-14 08:02:43 +03:00
Result<MoveAlongSurfaceResult> result = query.moveAlongSurface(startRef, startPos, endPos, filter);
Assert.That(result.succeeded(), Is.True);
MoveAlongSurfaceResult path = result.result;
2023-03-16 19:48:49 +03:00
for (int v = 0; v < 3; v++)
{
2023-03-14 08:02:43 +03:00
Assert.That(path.getResultPos()[v], Is.EqualTo(POSITION[i][v]).Within(0.01f));
}
2023-03-16 19:48:49 +03:00
2023-03-14 08:02:43 +03:00
Assert.That(path.getVisited().Count, Is.EqualTo(VISITED[i].Length));
2023-03-16 19:48:49 +03:00
for (int j = 0; j < POSITION[i].Length; j++)
{
2023-03-14 08:02:43 +03:00
Assert.That(path.getVisited()[j], Is.EqualTo(VISITED[i][j]));
}
}
}
2023-03-16 19:48:49 +03:00
}