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;
|
2023-10-16 17:55:34 +03:00
|
|
|
using DotRecast.Core;
|
2023-03-14 08:02:43 +03:00
|
|
|
|
|
|
|
namespace DotRecast.Recast.Test;
|
|
|
|
|
2023-06-08 14:53:03 +03:00
|
|
|
using static RcConstants;
|
2023-03-14 08:02:43 +03:00
|
|
|
|
2023-04-25 17:22:44 +03:00
|
|
|
[Parallelizable]
|
2023-03-14 08:02:43 +03:00
|
|
|
public class RecastTest
|
|
|
|
{
|
|
|
|
[Test]
|
2023-05-05 02:44:48 +03:00
|
|
|
public void TestClearUnwalkableTriangles()
|
2023-03-14 08:02:43 +03:00
|
|
|
{
|
|
|
|
float walkableSlopeAngle = 45;
|
|
|
|
float[] verts = { 0, 0, 0, 1, 0, 0, 0, 0, -1 };
|
|
|
|
int nv = 3;
|
|
|
|
int[] walkable_tri = { 0, 1, 2 };
|
|
|
|
int[] unwalkable_tri = { 0, 2, 1 };
|
|
|
|
int nt = 1;
|
|
|
|
|
2023-07-01 06:50:25 +03:00
|
|
|
RcTelemetry ctx = new RcTelemetry();
|
2023-03-14 08:02:43 +03:00
|
|
|
{
|
|
|
|
int[] areas = { 42 };
|
2023-09-22 17:42:21 +03:00
|
|
|
RcCommons.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, unwalkable_tri, nt, areas);
|
2023-03-14 08:02:43 +03:00
|
|
|
Assert.That(areas[0], Is.EqualTo(RC_NULL_AREA), "Sets area ID of unwalkable triangle to RC_NULL_AREA");
|
|
|
|
}
|
|
|
|
{
|
|
|
|
int[] areas = { 42 };
|
2023-09-22 17:42:21 +03:00
|
|
|
RcCommons.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, walkable_tri, nt, areas);
|
2023-03-14 08:02:43 +03:00
|
|
|
Assert.That(areas[0], Is.EqualTo(42), "Does not modify walkable triangle aread ID's");
|
|
|
|
}
|
|
|
|
{
|
|
|
|
int[] areas = { 42 };
|
|
|
|
walkableSlopeAngle = 0;
|
2023-09-22 17:42:21 +03:00
|
|
|
RcCommons.ClearUnwalkableTriangles(ctx, walkableSlopeAngle, verts, nv, walkable_tri, nt, areas);
|
2023-03-14 08:02:43 +03:00
|
|
|
Assert.That(areas[0], Is.EqualTo(RC_NULL_AREA), "Slopes equal to the max slope are considered unwalkable.");
|
|
|
|
}
|
|
|
|
}
|
2023-04-29 07:29:40 +03:00
|
|
|
}
|