Compare commits
2 Commits
39f20c8e01
...
83265f5838
Author | SHA1 | Date |
---|---|---|
Martin Felis | 83265f5838 | |
Martin Felis | 7627aa3699 |
|
@ -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 endPlane = new Vector2(endWorld.x, endWorld.z);
|
||||
|
|
|
@ -254,7 +254,14 @@ public class StreamContainer : Spatial
|
|||
{
|
||||
int instanceIndex = _tileToInstanceIndex[tile3D];
|
||||
|
||||
Transform instanceTransform = new Transform(tile3D.GlobalTransform.basis.Rotated(Vector3.Up, Mathf.Deg2Rad(30)), tile3D.GlobalTransform.origin + Vector3.Up * -2.5f);
|
||||
Vector3 scale = Vector3.One;
|
||||
if (ShowHexTiles)
|
||||
{
|
||||
scale.x *= 0.96f;
|
||||
scale.z *= 0.96f;
|
||||
}
|
||||
|
||||
Transform instanceTransform = new Transform(tile3D.GlobalTransform.basis.Rotated(Vector3.Up, Mathf.Deg2Rad(30)).Scaled(scale), tile3D.GlobalTransform.origin + Vector3.Up * -2.5f);
|
||||
|
||||
_tileMultiMesh.Multimesh.SetInstanceTransform(instanceIndex, instanceTransform);
|
||||
}
|
||||
|
|
|
@ -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