Example #1
0
        private MyMath.Point getCornerVertex(PointInt point, int dir)
        {
            MyMath.Point pointF = (MyMath.Point)point;

            MyMath.Point face = pointF + cornerPos[dir];
            return(face);
        }
Example #2
0
 public void Add(MyMath.Point p)
 {
     Border.Add(p);
 }
Example #3
0
        private void calculateBounds(Edge edge, int direction, int[,] biomeMap)
        {
            Direction dir   = new Direction(direction);
            var       point = edge.touchPoint;

            MyMath.Point startFace = getFace(point, dir);
            int          previousNeighbourBiome = biomeMap.getBorderValue(point, dir);

            dir.Increment();
            if (holes.Any(x => x.Border.Any(y => y.Equal(startFace))))
            {
                return;
            }
            Hole     border       = new Hole(edge.otherTouchPoint);
            PointInt currentPoint = point;

            while (true)
            {
                int newNeighbourBiome = biomeMap.getBorderValue(currentPoint, dir);
                if (!biomeMap.sameAsNeighbor(currentPoint, dir))
                {
                    if (!dir.Diagonal())
                    {
                        if (previousNeighbourBiome != newNeighbourBiome)
                        {
                            border.Add(getCornerVertex(currentPoint, dir));
                            previousNeighbourBiome = newNeighbourBiome;
                        }
                        MyMath.Point face = getFace(currentPoint, dir);
                        if (face.Equal(startFace))
                        {
                            break;
                        }
                        else
                        {
                            border.Add(face);
                        }
                    }
                    dir.Increment();
                }
                else
                {
                    currentPoint = currentPoint.Neighbor(dir);
                    if (dir.Diagonal())
                    {
                        dir.Decrement();
                    }
                    dir.Decrement();
                    if (dir.Diagonal())
                    {
                        dir.Decrement();
                    }
                }
            }
            if (border.Border.Count == 0)
            {
                throw new Exception();
            }
            border.Add(startFace);
            holes.Add(border);
        }
Example #4
0
 private MyMath.Point getFace(PointInt point, int dir)
 {
     MyMath.Point pointF = (MyMath.Point)point;
     MyMath.Point face   = pointF + facePos[dir];
     return(face);
 }
Example #5
0
 public static Vertex getVertex(this MyMath.Point p, int m)
 {
     return(new Vertex(p.x, p.y, m));
 }