Example #1
0
	/// <summary>
	/// Initializes a new instance of the <see cref="DBDBOPAgent"/> class.
	/// </summary>
	/// <param name="_searchMaster">_search master.</param>
	/// <param name="_grid">_grid.</param>
	/// <param name="_startNode">_start node.</param>
	/// <param name="_targetNode">_target node.</param>
	/// <param name="_nodesToExpand">_nodes to expand.</param>
    public DBDBOPAgent(DynBiDirBeamPath _searchMaster, Node[,] _grid, Node _startNode, Node _targetNode, int _nodesToExpand)
    {
        searchMaster = _searchMaster;
        grid = _grid;
        startNode = _startNode;
        targetNode = _targetNode;
        nodesToExpand = _nodesToExpand;
        openSet = new Heap<Node>(grid.GetLength(0) * grid.GetLength(1));
        closedSet = new HashSet<Node>();
        agentResult = new AgentResult(false);
        doneEvent = new ManualResetEvent(false);
    }
Example #2
0
    /// <summary>
    /// Performs Dynamic Bi-Directional search through a grid on
    /// a new thread
    /// </summary>
    /// <param name="startPos">Start position.</param>
    /// <param name="targetPos">Target position.</param>
    /// <param name="callback">Callback.</param>
    /// <param name="pathId">Path identifier.</param>
    public IEnumerator DynamicBiDirectional(Vector3 startPos, Vector3 targetPos, Action<Vector3[], bool> callback, int pathId, float totalMs)
    {
        //Added for mesh copy O(n2) heavy
        Node[,] meshCopy = grid.GetGridCopy();

        //Done for frame processing take over
        yield return null;

        UnityEngine.Debug.Log("Going into DynamicBiDirectional Thread");
        DynBiDirBeamPath dynPath = new DynBiDirBeamPath(grid, meshCopy, startPos, targetPos, callback, pathId, totalMs);
        paths.Add(dynPath);

        //Starts a new thread using threadpool management
        ThreadPool.QueueUserWorkItem(dynPath.ThreadPoolCallback, paths.Count);
    }