예제 #1
0
 public void createBorderGeometry()
 {
     foreach (Cell cell in cells.Values)
     {
         var v = cell.center;
         foreach (Vector3 v2 in VoxelIterators.VonNeumanNeighbors3D())
         {
             if (cells.ContainsKey(v2 + v))
             {
                 cell.neighbors.Add(v2 + v);
                 cell.removeWall(cells[v2 + v]);
                 cells[v2 + v].removeWall(cell);
             }
         }
     }
 }
예제 #2
0
 public static void recurse(Vector3 v, HashSet <Vector3> points, HashSet <Vector3> visitedPoints)
 {
     if (visitedPoints.Contains(v))
     {
         return;
     }
     visitedPoints.Add(v);
     points.Remove(v);
     foreach (Vector3 v2 in VoxelIterators.VonNeumanNeighbors3D())
     {
         var v3 = v2 + v;
         if (points.Contains(v3))
         {
             recurse(v3, points, visitedPoints);
         }
     }
 }
예제 #3
0
        public static List <Shape> WallUnion(Room a, Room b)
        {
            var walls = new List <Shape>();

            foreach (Vector3 v in a.pointsInRoom)
            {
                foreach (Vector3 v2 in VoxelIterators.VonNeumanNeighbors3D())
                {
                    var v3 = v + v2;
                    if (b.pointsInRoom.Contains(v3))
                    {
                        var c = a.cells[v].walls;
                        var d = b.cells[v3].walls;
                        walls.AddRange(c.Intersect(d));
                    }
                }
            }
            return(walls);
        }
예제 #4
0
        public static Dictionary <Cell, Cell> touchingCells(Room a, Room b)
        {
            Dictionary <Cell, Cell> d = new Dictionary <Cell, Cell>();

            foreach (Vector3 v in a.pointsInRoom)
            {
                foreach (Vector3 v2 in VoxelIterators.VonNeumanNeighbors3D())
                {
                    var v3 = v + v2;
                    if (b.pointsInRoom.Contains(v3))
                    {
                        var c1 = a.cells[v];
                        var c2 = b.cells[v3];
                        d[a.cells[v]] = b.cells[v3];
                    }
                }
            }
            return(d);
        }
예제 #5
0
        public static EdgeMap constructEdgemapFromPoints(IEnumerable <Vector3> input)
        {
            var edgeMap = new EdgeMap();
            var edges   = new HashSet <Edge>();

            foreach (Vector3 v in input)
            {
                foreach (Vector3 v2 in VoxelIterators.VonNeumanNeighbors3D())
                {
                    var v3 = v + v2;
                    if (input.Contains(v3))
                    {
                        edges.Add(new Edge(v, v3));
                    }
                }
            }

            foreach (Edge e in edges)
            {
                edgeMap.addElement(e);
            }
            return(edgeMap);
        }