Пример #1
0
        public VisualSidedefSlope(BaseVisualMode mode, SectorLevel level, Sidedef sidedef, bool up) : base(mode, level, up)
        {
            this.sidedef = sidedef;
            type         = VisualSlopeType.Line;

            Update();

            // We have no destructor
            GC.SuppressFinalize(this);
        }
        public static void ApplySlope(SectorLevel level, Plane plane, BaseVisualMode mode)
        {
            bool applytoceiling = false;

            Vector2D center = new Vector2D(level.sector.BBox.X + level.sector.BBox.Width / 2,
                                           level.sector.BBox.Y + level.sector.BBox.Height / 2);

            if (level.extrafloor)
            {
                // The top side of 3D floors is the ceiling of the sector, but it's a "floor" in UDB, so the
                // ceiling of the control sector has to be modified
                if (level.type == SectorLevelType.Floor)
                {
                    applytoceiling = true;
                }
            }
            else
            {
                if (level.type == SectorLevelType.Ceiling)
                {
                    applytoceiling = true;
                }
            }

            if (applytoceiling)
            {
                Plane downplane = plane.GetInverted();
                level.sector.CeilSlope       = downplane.Normal;
                level.sector.CeilSlopeOffset = downplane.Offset;
                level.sector.CeilHeight      = (int)new Plane(level.sector.CeilSlope, level.sector.CeilSlopeOffset).GetZ(center);
            }
            else
            {
                level.sector.FloorSlope       = plane.Normal;
                level.sector.FloorSlopeOffset = plane.Offset;
                level.sector.FloorHeight      = (int)new Plane(level.sector.FloorSlope, level.sector.FloorSlopeOffset).GetZ(center);
            }

            // Rebuild sector
            BaseVisualSector vs;

            if (mode.VisualSectorExists(level.sector))
            {
                vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
            }
            else
            {
                vs = mode.CreateBaseVisualSector(level.sector);
            }

            if (vs != null)
            {
                vs.UpdateSectorGeometry(true);
            }
        }
Пример #3
0
        public VisualVertexSlope(BaseVisualMode mode, SectorLevel level, Vertex vertex, Sector sector, bool up) : base(mode, level, up)
        {
            this.vertex = vertex;
            this.sector = sector;

            type = VisualSlopeType.Vertex;

            ComputeAngle();

            Update();

            GC.SuppressFinalize(this);
        }
        public VisualSidedefSlope(BaseVisualMode mode, SectorLevel level, Sidedef sidedef, bool up) : base()
        {
            this.mode    = mode;
            this.sidedef = sidedef;
            this.level   = level;
            this.up      = up;

            // length = sidedef.Line.Length;

            Update();

            // We have no destructor
            GC.SuppressFinalize(this);
        }
Пример #5
0
 public BaseVisualSlope(BaseVisualMode mode, SectorLevel level, bool up)
 {
     this.mode  = mode;
     this.level = level;
     this.up    = up;
 }
Пример #6
0
        public static void ApplySlope(SectorLevel level, Plane plane, BaseVisualMode mode)
        {
            bool applytoceiling = false;
            bool reset          = false;
            int  height         = 0;


            Vector2D center = new Vector2D(level.sector.BBox.X + level.sector.BBox.Width / 2,
                                           level.sector.BBox.Y + level.sector.BBox.Height / 2);

            if (level.extrafloor)
            {
                // The top side of 3D floors is the ceiling of the sector, but it's a "floor" in UDB, so the
                // ceiling of the control sector has to be modified
                if (level.type == SectorLevelType.Floor)
                {
                    applytoceiling = true;
                }
            }
            else
            {
                if (level.type == SectorLevelType.Ceiling)
                {
                    applytoceiling = true;
                }
            }

            // If the plane horizontal remove the slope and set the sector height instead
            // Rounding errors can result in offsets of horizontal planes to be a tiny, tiny bit off a whole number,
            // assume we want to remove the plane in this case
            double diff = Math.Abs(Math.Round(plane.d) - plane.d);

            if (plane.Normal.z == 1.0 && diff < 0.000000001)
            {
                reset  = true;
                height = -Convert.ToInt32(plane.d);
            }

            if (applytoceiling)
            {
                if (reset)
                {
                    level.sector.CeilHeight      = height;
                    level.sector.CeilSlope       = new Vector3D();
                    level.sector.CeilSlopeOffset = double.NaN;
                }
                else
                {
                    Plane downplane = plane.GetInverted();
                    level.sector.CeilSlope       = downplane.Normal;
                    level.sector.CeilSlopeOffset = downplane.Offset;
                }
            }
            else
            {
                if (reset)
                {
                    level.sector.FloorHeight      = height;
                    level.sector.FloorSlope       = new Vector3D();
                    level.sector.FloorSlopeOffset = double.NaN;
                }
                else
                {
                    level.sector.FloorSlope       = plane.Normal;
                    level.sector.FloorSlopeOffset = plane.Offset;
                }
            }

            // Rebuild sector
            BaseVisualSector vs;

            if (mode.VisualSectorExists(level.sector))
            {
                vs = (BaseVisualSector)mode.GetVisualSector(level.sector);
            }
            else
            {
                vs = mode.CreateBaseVisualSector(level.sector);
            }

            if (vs != null)
            {
                vs.UpdateSectorGeometry(true);
            }
        }