예제 #1
0
        public LineDef(
            Vertex vertex1,
            Vertex vertex2,
            LineFlags flags,
            LineSpecial special,
            short tag,
            SideDef side0,
            SideDef side1)
        {
            Vertex1 = vertex1;
            Vertex2 = vertex2;
            Flags   = flags;
            Special = special;
            Tag     = tag;
            Side0   = side0;
            Side1   = side1;

            Dx = vertex2.X - vertex1.X;
            Dy = vertex2.Y - vertex1.Y;

            if (Dx == Fixed.Zero)
            {
                SlopeType = SlopeType.Vertical;
            }
            else if (Dy == Fixed.Zero)
            {
                SlopeType = SlopeType.Horizontal;
            }
            else
            {
                if (Dy / Dx > Fixed.Zero)
                {
                    SlopeType = SlopeType.Positive;
                }
                else
                {
                    SlopeType = SlopeType.Negative;
                }
            }

            Box = new Fixed[4];
            Box[ManagedDoom.Box.Top]    = Fixed.Max(vertex1.Y, vertex2.Y);
            Box[ManagedDoom.Box.Bottom] = Fixed.Min(vertex1.Y, vertex2.Y);
            Box[ManagedDoom.Box.Left]   = Fixed.Min(vertex1.X, vertex2.X);
            Box[ManagedDoom.Box.Right]  = Fixed.Max(vertex1.X, vertex2.X);

            FrontSector = side0?.Sector;
            BackSector  = side1?.Sector;
        }
예제 #2
0
        public LineDef(
            Vertex vertex1,
            Vertex vertex2,
            LineFlags flags,
            LineSpecial special,
            short tag,
            SideDef frontSide,
            SideDef backSide)
        {
            this.vertex1   = vertex1;
            this.vertex2   = vertex2;
            this.flags     = flags;
            this.special   = special;
            this.tag       = tag;
            this.frontSide = frontSide;
            this.backSide  = backSide;

            dx = vertex2.X - vertex1.X;
            dy = vertex2.Y - vertex1.Y;

            if (dx == Fixed.Zero)
            {
                slopeType = SlopeType.Vertical;
            }
            else if (dy == Fixed.Zero)
            {
                slopeType = SlopeType.Horizontal;
            }
            else
            {
                if (dy / dx > Fixed.Zero)
                {
                    slopeType = SlopeType.Positive;
                }
                else
                {
                    slopeType = SlopeType.Negative;
                }
            }

            boundingBox             = new Fixed[4];
            boundingBox[Box.Top]    = Fixed.Max(vertex1.Y, vertex2.Y);
            boundingBox[Box.Bottom] = Fixed.Min(vertex1.Y, vertex2.Y);
            boundingBox[Box.Left]   = Fixed.Min(vertex1.X, vertex2.X);
            boundingBox[Box.Right]  = Fixed.Max(vertex1.X, vertex2.X);

            frontSector = frontSide?.Sector;
            backSector  = backSide?.Sector;
        }