Added TestCase for which CheckSweptTriangleCellCollision does not terminate.
parent
7627aa3699
commit
83265f5838
|
@ -278,7 +278,7 @@ public class NavigationComponent : Spatial
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CheckSweptTriangleCellCollision(Vector3 startWorld, Vector3 endWorld, float radius)
|
public bool CheckSweptTriangleCellCollision(Vector3 startWorld, Vector3 endWorld, float radius)
|
||||||
{
|
{
|
||||||
Vector2 startPlane = new Vector2(startWorld.x, startWorld.z);
|
Vector2 startPlane = new Vector2(startWorld.x, startWorld.z);
|
||||||
Vector2 endPlane = new Vector2(endWorld.x, endWorld.z);
|
Vector2 endPlane = new Vector2(endWorld.x, endWorld.z);
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
using Godot;
|
||||||
|
using GoDotTest;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
public class NavigationComponentTests : TestClass
|
||||||
|
{
|
||||||
|
private Node _testScene = null;
|
||||||
|
private TileWorld _tileWorld;
|
||||||
|
private NavigationComponent _navigationComponent;
|
||||||
|
private KinematicBody _kinematicBody;
|
||||||
|
|
||||||
|
private PackedScene _tileWorldScene = GD.Load<PackedScene>("res://scenes/TileWorld.tscn");
|
||||||
|
|
||||||
|
public NavigationComponentTests(Node testScene) : base(testScene)
|
||||||
|
{
|
||||||
|
_testScene = testScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Setup]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
_tileWorld = (TileWorld)_tileWorldScene.Instance();
|
||||||
|
_tileWorld.HexGrid = new HexGrid();
|
||||||
|
_testScene.AddChild(_tileWorld);
|
||||||
|
_kinematicBody = new KinematicBody();
|
||||||
|
_navigationComponent = new NavigationComponent();
|
||||||
|
_navigationComponent.TileWorld = _tileWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SimpleTest()
|
||||||
|
{
|
||||||
|
_tileWorld.HexGrid.AddObstacle(HexCell.FromOffsetCoords(new Vector2 (-4, 7)));
|
||||||
|
|
||||||
|
Vector3 startPoint = new Vector3(-2.25f, 1.2f, -4.76314f);
|
||||||
|
Vector3 endPoint = new Vector3(-2.533157f, 1.2f, -5.872417f);
|
||||||
|
|
||||||
|
bool isBlocked = _navigationComponent.CheckSweptTriangleCellCollision(startPoint, endPoint, 0.27f);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue