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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
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 NavMeshBuilderTest
|
|
|
|
{
|
2023-06-08 15:38:02 +03:00
|
|
|
private DtMeshData nmd;
|
2023-03-14 08:02:43 +03:00
|
|
|
|
|
|
|
[SetUp]
|
2023-05-05 02:44:48 +03:00
|
|
|
public void SetUp()
|
2023-03-16 19:48:49 +03:00
|
|
|
{
|
2023-05-05 02:44:48 +03:00
|
|
|
nmd = new RecastTestMeshBuilder().GetMeshData();
|
2023-03-14 08:02:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2023-05-05 02:44:48 +03:00
|
|
|
public void TestBVTree()
|
2023-03-16 19:48:49 +03:00
|
|
|
{
|
2023-03-14 08:02:43 +03:00
|
|
|
Assert.That(nmd.verts.Length / 3, Is.EqualTo(225));
|
|
|
|
Assert.That(nmd.polys.Length, Is.EqualTo(119));
|
|
|
|
Assert.That(nmd.header.maxLinkCount, Is.EqualTo(457));
|
|
|
|
Assert.That(nmd.detailMeshes.Length, Is.EqualTo(118));
|
|
|
|
Assert.That(nmd.detailTris.Length / 4, Is.EqualTo(291));
|
|
|
|
Assert.That(nmd.detailVerts.Length / 3, Is.EqualTo(60));
|
|
|
|
Assert.That(nmd.offMeshCons.Length, Is.EqualTo(1));
|
|
|
|
Assert.That(nmd.header.offMeshBase, Is.EqualTo(118));
|
|
|
|
Assert.That(nmd.bvTree.Length, Is.EqualTo(236));
|
|
|
|
Assert.That(nmd.bvTree.Length, Is.GreaterThanOrEqualTo(nmd.header.bvNodeCount));
|
2023-03-16 19:48:49 +03:00
|
|
|
for (int i = 0; i < nmd.header.bvNodeCount; i++)
|
|
|
|
{
|
2023-03-14 08:02:43 +03:00
|
|
|
Assert.That(nmd.bvTree[i], Is.Not.Null);
|
|
|
|
}
|
2023-03-16 19:48:49 +03:00
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
{
|
2023-03-14 08:02:43 +03:00
|
|
|
Assert.That(nmd.verts[223 * 3 + i], Is.EqualTo(nmd.offMeshCons[0].pos[i]));
|
|
|
|
}
|
2023-03-16 19:48:49 +03:00
|
|
|
|
2023-03-14 08:02:43 +03:00
|
|
|
Assert.That(nmd.offMeshCons[0].rad, Is.EqualTo(0.1f));
|
|
|
|
Assert.That(nmd.offMeshCons[0].poly, Is.EqualTo(118));
|
2023-06-08 15:38:02 +03:00
|
|
|
Assert.That(nmd.offMeshCons[0].flags, Is.EqualTo(DtNavMesh.DT_OFFMESH_CON_BIDIR));
|
2023-03-14 08:02:43 +03:00
|
|
|
Assert.That(nmd.offMeshCons[0].side, Is.EqualTo(0xFF));
|
|
|
|
Assert.That(nmd.offMeshCons[0].userId, Is.EqualTo(0x4567));
|
|
|
|
Assert.That(nmd.polys[118].vertCount, Is.EqualTo(2));
|
|
|
|
Assert.That(nmd.polys[118].verts[0], Is.EqualTo(223));
|
|
|
|
Assert.That(nmd.polys[118].verts[1], Is.EqualTo(224));
|
|
|
|
Assert.That(nmd.polys[118].flags, Is.EqualTo(12));
|
2023-05-05 02:44:48 +03:00
|
|
|
Assert.That(nmd.polys[118].GetArea(), Is.EqualTo(2));
|
2023-06-08 15:38:02 +03:00
|
|
|
Assert.That(nmd.polys[118].GetPolyType(), Is.EqualTo(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION));
|
2023-03-14 08:02:43 +03:00
|
|
|
}
|
2023-04-29 07:29:40 +03:00
|
|
|
}
|