// This makes sure we are updated with the source linedef information
        public override void Update()
        {
            SectorData sd = data.Mode.GetSectorData(linedef.Front.Sector);

            if (!sd.Updated)
            {
                sd.Update();
            }
            sd.AddUpdateSector(data.Sector, false);

            // Transfer ceiling brightness, keep sector color
            PixelColor lightcolor = PixelColor.FromInt(data.Sector.Fields.GetValue("lightcolor", -1));
            PixelColor brightness = PixelColor.FromInt(General.Map.Renderer3D.CalculateBrightness(sd.Sector.Brightness));

            data.Ceiling.color = PixelColor.Modulate(lightcolor, brightness).WithAlpha(255).ToInt();
        }
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            //mxd. Skip if arg0 is 0.
            if (thing.Args[0] == 0)
            {
                return;
            }

            ThingData td = data.Mode.GetThingData(thing);
            Thing     t  = thing;
            Linedef   ld = sidedef.Line;

            if (ld != null)
            {
                if (t.Type == 9500)
                {
                    SectorData sd = data.Mode.GetSectorData(sidedef.Sector);
                    Vector3D   v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, sd.Floor.plane.GetZ(ld.Start.Position));
                    Vector3D   v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, sd.Floor.plane.GetZ(ld.End.Position));
                    Vector3D   v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + sd.Floor.plane.GetZ(t.Position));
                    sd.AddUpdateSector(data.Sector, true);
                    if (!sd.Updated)
                    {
                        sd.Update();
                    }
                    td.AddUpdateSector(sidedef.Sector, true);
                    sd.Floor.plane = new Plane(v1, v2, v3, true);
                }
                else if (t.Type == 9501)
                {
                    SectorData sd = data.Mode.GetSectorData(sidedef.Sector);
                    Vector3D   v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, sd.Ceiling.plane.GetZ(ld.Start.Position));
                    Vector3D   v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, sd.Ceiling.plane.GetZ(ld.End.Position));
                    Vector3D   v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + sd.Ceiling.plane.GetZ(t.Position));
                    sd.AddUpdateSector(data.Sector, true);
                    if (!sd.Updated)
                    {
                        sd.Update();
                    }
                    td.AddUpdateSector(sidedef.Sector, true);
                    sd.Ceiling.plane = new Plane(v1, v2, v3, false);
                }
            }
        }
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            SectorData sd = data.Mode.GetSectorData(linedef.Front.Sector);

            if (!sd.Updated)
            {
                sd.Update();
            }
            sd.AddUpdateSector(data.Sector, false);

            // Create top level?
            if (toplevel == null)
            {
                toplevel = new SectorLevel(sd.Ceiling);
                data.AddSectorLevel(toplevel);
            }

            // Update top level
            sd.Ceiling.CopyProperties(toplevel);
            toplevel.lighttype = (LightLevelType)General.Clamp(linedef.Args[1], 0, 2);             //mxd
            toplevel.type      = SectorLevelType.Light;

            //mxd. Create bottom level?
            if (toplevel.lighttype == LightLevelType.TYPE1)
            {
                // Create bottom level? Skip this step if there's a different light level between toplevel and bottomlevel
                if (bottomlevel == null)
                {
                    bottomlevel = new SectorLevel(data.Ceiling);
                    data.AddSectorLevel(bottomlevel);
                }

                // Update bottom level
                data.Ceiling.CopyProperties(bottomlevel);
                bottomlevel.type      = SectorLevelType.Light;
                bottomlevel.lighttype = LightLevelType.TYPE1_BOTTOM;
                bottomlevel.plane     = sd.Floor.plane.GetInverted();
            }
        }
Esempio n. 4
0
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            // Find tagged sector
            Sector sourcesector = null;

            foreach (Sector s in General.Map.Map.Sectors)
            {
                if (s.Tags.Contains(thing.Args[0]))
                {
                    sourcesector = s;
                    break;
                }
            }

            if (sourcesector != null)
            {
                SectorData sourcesectordata = data.Mode.GetSectorData(sourcesector);
                if (!sourcesectordata.Updated)
                {
                    sourcesectordata.Update();
                }

                switch (thing.Type)
                {
                case 9510:
                    data.Floor.plane = sourcesectordata.Floor.plane;
                    break;

                case 9511:
                    data.Ceiling.plane = sourcesectordata.Ceiling.plane;
                    break;
                }

                sourcesectordata.AddUpdateSector(data.Sector, true);
            }
        }
Esempio n. 5
0
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            ThingData td = data.Mode.GetThingData(thing);
            Thing     t  = thing;

            // Floor slope thing
            if (t.Type == 9502)
            {
                t.DetermineSector(data.Mode.BlockMap);
                if (t.Sector != null)
                {
                    //mxd. Vertex zheight overrides this effect
                    if (General.Map.UDMF && t.Sector.Sidedefs.Count == 3)
                    {
                        foreach (Sidedef side in t.Sector.Sidedefs)
                        {
                            if (!double.IsNaN(side.Line.Start.ZFloor) || !double.IsNaN(side.Line.End.ZFloor))
                            {
                                return;
                            }
                        }
                    }

                    double   angle         = Angle2D.DoomToReal((int)Angle2D.RadToDeg(t.Angle));
                    double   vangle        = Angle2D.DegToRad(General.Clamp(t.Args[0], 0, 180));            //mxd. Don't underestimate user stupidity (or curiosity)!
                    Vector2D point         = new Vector2D(t.Position.x + Math.Cos(angle) * Math.Sin(vangle), t.Position.y + Math.Sin(angle) * Math.Sin(vangle));
                    Vector2D perpendicular = new Line2D(t.Position, point).GetPerpendicular();

                    Vector3D v1 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + t.Sector.FloorHeight);

                    Vector3D v2 = new Vector3D(
                        point.x + perpendicular.x,
                        point.y + perpendicular.y,
                        t.Position.z + t.Sector.FloorHeight + Math.Cos(vangle)
                        );

                    Vector3D v3 = new Vector3D(
                        point.x - perpendicular.x,
                        point.y - perpendicular.y,
                        t.Position.z + t.Sector.FloorHeight + Math.Cos(vangle)
                        );

                    SectorData sd = data.Mode.GetSectorData(t.Sector);
                    sd.AddUpdateSector(data.Sector, true);
                    if (!sd.Updated)
                    {
                        sd.Update();
                    }
                    td.AddUpdateSector(t.Sector, true);
                    sd.Floor.plane = new Plane(v1, v2, v3, true);
                }
            }
            // Ceiling slope thing
            else if (t.Type == 9503)
            {
                t.DetermineSector(data.Mode.BlockMap);
                if (t.Sector != null)
                {
                    //mxd. Vertex zheight overrides this effect
                    if (General.Map.UDMF && t.Sector.Sidedefs.Count == 3)
                    {
                        foreach (Sidedef side in t.Sector.Sidedefs)
                        {
                            if (!double.IsNaN(side.Line.Start.ZCeiling) || !double.IsNaN(side.Line.End.ZCeiling))
                            {
                                return;
                            }
                        }
                    }

                    double   angle         = Angle2D.DoomToReal((int)Angle2D.RadToDeg(t.Angle));
                    double   vangle        = Angle2D.DegToRad(General.Clamp(t.Args[0], 0, 180));            //mxd. Don't underestimate user stupidity (or curiosity)!
                    Vector2D point         = new Vector2D(t.Position.x + Math.Cos(angle) * Math.Sin(vangle), t.Position.y + Math.Sin(angle) * Math.Sin(vangle));
                    Vector2D perpendicular = new Line2D(t.Position, point).GetPerpendicular();

                    Vector3D v1 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + t.Sector.CeilHeight);

                    Vector3D v2 = new Vector3D(
                        point.x + perpendicular.x,
                        point.y + perpendicular.y,
                        t.Position.z + t.Sector.CeilHeight + Math.Cos(vangle)
                        );

                    Vector3D v3 = new Vector3D(
                        point.x - perpendicular.x,
                        point.y - perpendicular.y,
                        t.Position.z + t.Sector.CeilHeight + Math.Cos(vangle)
                        );

                    SectorData sd = data.Mode.GetSectorData(t.Sector);
                    sd.AddUpdateSector(data.Sector, true);
                    if (!sd.Updated)
                    {
                        sd.Update();
                    }
                    td.AddUpdateSector(t.Sector, true);
                    sd.Ceiling.plane = new Plane(v1, v2, v3, false);
                }
            }
        }
Esempio n. 6
0
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            Sector     sourcesector     = null;
            SectorData sourcesectordata = null;
            bool       updatesides      = false;

            // Copy slopes from tagged sectors
            //check which arguments we must use
            int floorArg   = (front ? 0 : 2);
            int ceilingArg = (front ? 1 : 3);

            //find sector to align floor to
            if (linedef.Args[floorArg] > 0)
            {
                foreach (Sector s in General.Map.Map.Sectors)
                {
                    if (s.Tags.Contains(linedef.Args[floorArg]))
                    {
                        sourcesector = s;
                        break;
                    }
                }

                if (sourcesector != null)
                {
                    sourcesectordata = data.Mode.GetSectorData(sourcesector);
                    if (!sourcesectordata.Updated)
                    {
                        sourcesectordata.Update();
                    }

                    data.Floor.plane = sourcesectordata.Floor.plane;
                    sourcesectordata.AddUpdateSector(data.Sector, true);

                    updatesides = true;
                }
            }

            if (linedef.Args[ceilingArg] > 0)
            {
                //find sector to align ceiling to
                if (linedef.Args[ceilingArg] != linedef.Args[floorArg])
                {
                    sourcesector = null;

                    foreach (Sector s in General.Map.Map.Sectors)
                    {
                        if (s.Tags.Contains(linedef.Args[ceilingArg]))
                        {
                            sourcesector = s;
                            break;
                        }
                    }

                    if (sourcesector != null)
                    {
                        sourcesectordata = data.Mode.GetSectorData(sourcesector);
                        if (!sourcesectordata.Updated)
                        {
                            sourcesectordata.Update();
                        }

                        data.Ceiling.plane = sourcesectordata.Ceiling.plane;
                        sourcesectordata.AddUpdateSector(data.Sector, true);

                        updatesides = true;
                    }
                }
                else if (sourcesector != null)                //ceiling uses the same sector as floor
                {
                    data.Ceiling.plane = sourcesectordata.Ceiling.plane;
                }
            }

            //check the flags...
            bool copyFloor   = false;
            bool copyCeiling = false;

            if (linedef.Args[4] > 0 && linedef.Args[4] != 3 && linedef.Args[4] != 12)
            {
                if (front)
                {
                    copyFloor   = (linedef.Args[4] & 2) == 2;
                    copyCeiling = (linedef.Args[4] & 8) == 8;
                }
                else
                {
                    copyFloor   = (linedef.Args[4] & 1) == 1;
                    copyCeiling = (linedef.Args[4] & 4) == 4;
                }
            }

            // Copy slope across the line
            if ((copyFloor || copyCeiling) && linedef.Front != null && linedef.Back != null)
            {
                // Get appropriate source sector data
                sourcesectordata = data.Mode.GetSectorData(front ? linedef.Back.Sector : linedef.Front.Sector);
                if (!sourcesectordata.Updated)
                {
                    sourcesectordata.Update();
                }

                //copy floor slope?
                if (copyFloor)
                {
                    data.Floor.plane = sourcesectordata.Floor.plane;
                    sourcesectordata.AddUpdateSector(data.Sector, true);
                }

                //copy ceiling slope?
                if (copyCeiling)
                {
                    data.Ceiling.plane = sourcesectordata.Ceiling.plane;
                    sourcesectordata.AddUpdateSector(data.Sector, true);
                }

                updatesides = true;
            }

            // Update outer sidedef geometry
            if (updatesides)
            {
                UpdateSectorSides(data.Sector);

                // Update sectors with PlaneCopySlope Effect...
                List <SectorData> toupdate = new List <SectorData>();
                foreach (Sector s in data.UpdateAlso.Keys)
                {
                    SectorData osd = data.Mode.GetSectorDataEx(s);
                    if (osd == null)
                    {
                        continue;
                    }
                    foreach (SectorEffect e in osd.Effects)
                    {
                        if (e is EffectPlaneCopySlope)
                        {
                            toupdate.Add(osd);
                            break;
                        }
                    }
                }

                // Do it in 2 steps, because SectorData.Reset() may change SectorData.UpdateAlso collection...
                foreach (SectorData sd in toupdate)
                {
                    // Update PlaneCopySlope Effect...
                    sd.Reset(false);

                    // Update outer sides...
                    UpdateSectorSides(sd.Sector);
                }
            }
        }
Esempio n. 7
0
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            //mxd. Skip if arg0 is 0.
            if (thing.Args[0] == 0)
            {
                return;
            }

            ThingData td = data.Mode.GetThingData(thing);
            Thing     t  = thing;

            // Find the tagged line
            Linedef ld = null;

            foreach (Linedef l in General.Map.Map.Linedefs)
            {
                if (l.Tags.Contains(t.Args[0]))
                {
                    ld = l;
                    break;
                }
            }

            if (ld != null)
            {
                if (t.Type == 9500)
                {
                    // Slope the floor from the linedef to thing
                    t.DetermineSector(data.Mode.BlockMap);
                    if (t.Sector != null)
                    {
                        Vector3D v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + t.Sector.FloorHeight);
                        if (ld.SideOfLine(t.Position) < 0.0f)
                        {
                            Vector3D   v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, ld.Front.Sector.FloorHeight);
                            Vector3D   v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, ld.Front.Sector.FloorHeight);
                            SectorData sd = data.Mode.GetSectorData(ld.Front.Sector);
                            sd.AddUpdateSector(data.Sector, true);
                            if (!sd.Updated)
                            {
                                sd.Update();
                            }
                            td.AddUpdateSector(ld.Front.Sector, true);
                            sd.Floor.plane = new Plane(v1, v2, v3, true);
                        }
                        else
                        {
                            Vector3D   v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, ld.Back.Sector.FloorHeight);
                            Vector3D   v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, ld.Back.Sector.FloorHeight);
                            SectorData sd = data.Mode.GetSectorData(ld.Back.Sector);
                            sd.AddUpdateSector(data.Sector, true);
                            if (!sd.Updated)
                            {
                                sd.Update();
                            }
                            td.AddUpdateSector(ld.Back.Sector, true);
                            sd.Floor.plane = new Plane(v2, v1, v3, true);
                        }
                    }
                }
                else if (t.Type == 9501)
                {
                    // Slope the ceiling from the linedef to thing
                    t.DetermineSector(data.Mode.BlockMap);
                    if (t.Sector != null)
                    {
                        td.AddUpdateSector(t.Sector, true);
                        Vector3D v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + t.Sector.CeilHeight);
                        if (ld.SideOfLine(t.Position) < 0.0f)
                        {
                            Vector3D   v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, ld.Front.Sector.CeilHeight);
                            Vector3D   v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, ld.Front.Sector.CeilHeight);
                            SectorData sd = data.Mode.GetSectorData(ld.Front.Sector);
                            sd.AddUpdateSector(data.Sector, true);
                            td.AddUpdateSector(ld.Front.Sector, true);
                            if (!sd.Updated)
                            {
                                sd.Update();
                            }
                            sd.Ceiling.plane = new Plane(v1, v2, v3, false);
                        }
                        else
                        {
                            Vector3D   v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, ld.Back.Sector.CeilHeight);
                            Vector3D   v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, ld.Back.Sector.CeilHeight);
                            SectorData sd = data.Mode.GetSectorData(ld.Back.Sector);
                            sd.AddUpdateSector(data.Sector, true);
                            td.AddUpdateSector(ld.Back.Sector, true);
                            if (!sd.Updated)
                            {
                                sd.Update();
                            }
                            sd.Ceiling.plane = new Plane(v2, v1, v3, false);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            SectorData sd = data.Mode.GetSectorData(linedef.Front.Sector);

            if (!sd.Updated)
            {
                sd.Update();
            }
            sd.AddUpdateSector(data.Sector, true);

            if (floor == null)
            {
                floor = new SectorLevel(sd.Floor);
                data.AddSectorLevel(floor);
            }

            if (ceiling == null)
            {
                ceiling = new SectorLevel(sd.Ceiling);
                data.AddSectorLevel(ceiling);
            }

            // For non-vavoom types, we must switch the level types
            if (linedef.Args[1] != (int)FloorTypes.VavoomStyle)
            {
                //mxd. check for Swimmable/RenderInside/RenderAdditive flags
                renderadditive = (linedef.Args[2] & (int)Flags.RenderAdditive) == (int)Flags.RenderAdditive;
                renderinside   = ((((linedef.Args[1] & (int)FloorTypes.Swimmable) == (int)FloorTypes.Swimmable) && (linedef.Args[1] & (int)FloorTypes.NonSolid) != (int)FloorTypes.NonSolid)) ||
                                 ((linedef.Args[1] & (int)FloorTypes.RenderInside) == (int)FloorTypes.RenderInside);
                ignorebottomheight = ((linedef.Args[2] & (int)Flags.IgnoreBottomHeight) == (int)Flags.IgnoreBottomHeight);

                vavoomtype = false;
                alpha      = General.Clamp(linedef.Args[3], 0, 255);
                sd.Ceiling.CopyProperties(floor);
                sd.Floor.CopyProperties(ceiling);
                floor.type    = SectorLevelType.Floor;
                floor.plane   = sd.Ceiling.plane.GetInverted();
                ceiling.type  = SectorLevelType.Ceiling;
                ceiling.plane = (ignorebottomheight ? sd.Ceiling.plane : sd.Floor.plane.GetInverted());                 //mxd. Use upper plane when "ignorebottomheight" flag is set

                //mxd
                clipsides = (!renderinside && !renderadditive && alpha > 254 && !ignorebottomheight);

                // A 3D floor's color is always that of the sector it is placed in
                // (unless it's affected by glow) - mxd
                if (sd.CeilingGlow == null || !sd.CeilingGlow.Fullbright)
                {
                    floor.color = 0;
                }
            }
            else
            {
                vavoomtype     = true;
                renderadditive = false;           //mxd
                clipsides      = true;            //mxd
                floor.type     = SectorLevelType.Ceiling;
                floor.plane    = sd.Ceiling.plane;
                ceiling.type   = SectorLevelType.Floor;
                ceiling.plane  = sd.Floor.plane;
                alpha          = 255;

                // A 3D floor's color is always that of the sector it is placed in
                // (unless it's affected by glow) - mxd
                if (sd.FloorGlow == null || !sd.FloorGlow.Fullbright)
                {
                    ceiling.color = 0;
                }
            }

            // Apply alpha
            floor.alpha   = alpha;
            ceiling.alpha = alpha;

            //mxd
            floor.extrafloor   = true;
            ceiling.extrafloor = true;
            floor.splitsides   = !clipsides;
            ceiling.splitsides = (!clipsides && !ignorebottomheight);             // if "ignorebottomheight" flag is set, both ceiling and floor will be at the same level and sidedef clipping with floor level will fail resulting in incorrect light props transfer in some cases

            //mxd. Check slopes, cause GZDoom can't handle sloped translucent 3d floors...
            sloped3dfloor = ((alpha < 255 || renderadditive) &&
                             (Angle2D.RadToDeg(ceiling.plane.Normal.GetAngleZ()) != 270 ||
                              Angle2D.RadToDeg(floor.plane.Normal.GetAngleZ()) != 90));

            // Do not adjust light? (works only for non-vavoom types)
            if (!vavoomtype)
            {
                bool disablelighting  = ((linedef.Args[2] & (int)Flags.DisableLighting) == (int)Flags.DisableLighting);             //mxd
                bool restrictlighting = ((linedef.Args[2] & (int)Flags.RestrictLighting) == (int)Flags.RestrictLighting);           //mxd
                floor.resetlighting = ((linedef.Args[2] & (int)Flags.ResetLighting) == (int)Flags.ResetLighting);                   //mxd

                if (disablelighting || restrictlighting)
                {
                    floor.restrictlighting = restrictlighting; //mxd
                    floor.disablelighting  = disablelighting;  //mxd

                    if (disablelighting)                       //mxd
                    {
                        floor.color           = 0;
                        floor.brightnessbelow = -1;
                        floor.colorbelow      = PixelColor.FromInt(0);
                    }

                    ceiling.disablelighting  = disablelighting;                    //mxd
                    ceiling.restrictlighting = restrictlighting;                   //mxd

                    ceiling.color           = 0;
                    ceiling.brightnessbelow = -1;
                    ceiling.colorbelow      = PixelColor.FromInt(0);
                }
            }
        }