remove all not coneccted nodes

master
Christopher Latza 2020-06-23 00:58:09 +02:00
parent 6dc278323a
commit 4830bbddd6
1 changed files with 10 additions and 0 deletions

View File

@ -7,6 +7,7 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.Api;
using Roy_T.AStar.Graphs;
using Roy_T.AStar.Grids;
using Roy_T.AStar.Paths;
using Roy_T.AStar.Primitives;
@ -427,6 +428,15 @@ namespace OpenSim.Modules.PathFinding
Velocity _pathFindingVelocity = Velocity.FromKilometersPerHour(11.5f);
Grid _pathFindingGrid = Grid.CreateGridWithLateralAndDiagonalConnections(_pathFindingGridSize, _pathFindingCellSize, _pathFindingVelocity);
foreach(INode _thisNode in _pathFindingGrid.GetAllNodes())
{
PathNode _node = _env.Nodes.Find(X => X.PositionX == (int)_thisNode.Position.X && X.PositionY == (int)_thisNode.Position.Y);
if(_node == null)
_pathFindingGrid.RemoveDiagonalConnectionsIntersectingWithNode(new GridPosition((int)_thisNode.Position.X, (int)_thisNode.Position.Y));
}
PathFinder pathFinder = new PathFinder();
Path _pathFindingPath = pathFinder.FindPath(new GridPosition(_startNode.PositionX, _startNode.PositionY), new GridPosition(_targetNode.PositionX, _targetNode.PositionY), _pathFindingGrid);