Example #1
0
 /// <summary>Adds obstacles for a navmesh/recast graph</summary>
 void AddGraphObstacles(Pathfinding.RVO.Simulator simulator, INavmesh navmesh)
 {
     GraphUtilities.GetContours(navmesh, (vertices, cycle) => {
         var verticesV3 = new Vector3[vertices.Count];
         for (int i = 0; i < verticesV3.Length; i++)
         {
             verticesV3[i] = (Vector3)vertices[i];
         }
         // Pool the 'vertices' list to reduce allocations
         ListPool <Int3> .Release(vertices);
         obstacles.Add(simulator.AddObstacle(verticesV3, wallHeight, cycle));
     });
 }
Example #2
0
        // Token: 0x060028F0 RID: 10480 RVA: 0x001BE988 File Offset: 0x001BCB88
        private void AddGraphObstacles(Simulator sim, GridGraph grid)
        {
            bool reverse = Vector3.Dot(grid.transform.TransformVector(Vector3.up), (sim.movementPlane == MovementPlane.XY) ? Vector3.back : Vector3.up) > 0f;

            GraphUtilities.GetContours(grid, delegate(Vector3[] vertices)
            {
                if (reverse)
                {
                    Array.Reverse(vertices);
                }
                this.obstacles.Add(sim.AddObstacle(vertices, this.wallHeight, true));
            }, this.wallHeight * 0.4f, null);
        }
Example #3
0
 // Token: 0x060028F1 RID: 10481 RVA: 0x001BEA04 File Offset: 0x001BCC04
 private void AddGraphObstacles(Simulator simulator, INavmesh navmesh)
 {
     GraphUtilities.GetContours(navmesh, delegate(List <Int3> vertices, bool cycle)
     {
         Vector3[] array = new Vector3[vertices.Count];
         for (int i = 0; i < array.Length; i++)
         {
             array[i] = (Vector3)vertices[i];
         }
         ListPool <Int3> .Release(vertices);
         this.obstacles.Add(simulator.AddObstacle(array, this.wallHeight, cycle));
     });
 }
Example #4
0
        /// <summary>Adds obstacles for a grid graph</summary>
        void AddGraphObstacles(Pathfinding.RVO.Simulator sim, GridGraph grid)
        {
            bool reverse = Vector3.Dot(grid.transform.TransformVector(Vector3.up), sim.movementPlane == MovementPlane.XY ? Vector3.back : Vector3.up) > 0;

            GraphUtilities.GetContours(grid, vertices => {
                // Check if the contour is traced in the wrong direction from the one we want it in.
                // If we did not do this then instead of the obstacles keeping the agents OUT of the walls
                // they would keep them INSIDE the walls.
                if (reverse)
                {
                    System.Array.Reverse(vertices);
                }
                obstacles.Add(sim.AddObstacle(vertices, wallHeight, true));
            }, wallHeight * 0.4f);
        }