diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySector.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySector.cs index 5b50b670..1abb9e52 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySector.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySector.cs @@ -61,6 +61,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing new public BaseVisualSector Sector { get { return (BaseVisualSector)base.Sector; } } public bool Changed { get { return changed; } set { changed = value; } } + public SectorLevel Level { get { return level; } } #endregion @@ -298,7 +299,11 @@ namespace CodeImp.DoomBuilder.GZDoomEditing ChangeHeight(amount); // Rebuild sector - Sector.UpdateSectorGeometry(true); + if(mode.VisualSectorExists(level.sector)) + { + BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); + vs.UpdateSectorGeometry(true); + } } // Sector brightness change diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs index 88057f93..fff91cca 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualMode.cs @@ -762,11 +762,16 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Go for all sectors to update foreach(Sector s in General.Map.Map.Sectors) { - if(s.Marked && VisualSectorExists(s)) + if(s.Marked) { - BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s); - vs.Floor.Setup(); - vs.Ceiling.Setup(); + SectorData sd = GetSectorData(s); + sd.Reset(); + + if(VisualSectorExists(s)) + { + BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s); + vs.UpdateSectorGeometry(false); + } } } @@ -797,6 +802,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Make new blockmap if(sectorsmarked || General.Map.UndoRedo.PopulationChanged) FillBlockMap(); + + UpdateChangedObjects(); // Visibility culling (this re-creates the needed resources) DoCulling(); @@ -930,7 +937,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing { if(i is BaseVisualGeometrySector) { - Sector s = (i as BaseVisualGeometrySector).Sector.Sector; + Sector s = (i as BaseVisualGeometrySector).Level.sector; if(!added.ContainsKey(s)) { sectors.Add(s); @@ -942,7 +949,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Add highlight? if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySector)) { - Sector s = (target.picked as BaseVisualGeometrySector).Sector.Sector; + Sector s = (target.picked as BaseVisualGeometrySector).Level.sector; if(!added.ContainsKey(s)) sectors.Add(s); } diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualThing.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualThing.cs index 091c2bf9..e9605d3e 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualThing.cs @@ -98,9 +98,13 @@ namespace CodeImp.DoomBuilder.GZDoomEditing { if(Thing.Sector != null) { + SectorData sd = mode.GetSectorData(Thing.Sector); + SectorLevel level = sd.GetLevelAbove(new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + Thing.Sector.FloorHeight)); + // Use sector brightness for color shading - byte brightness = (byte)General.Clamp(Thing.Sector.Brightness, 0, 255); - sectorcolor = new PixelColor(255, brightness, brightness, brightness); + PixelColor areabrightness = PixelColor.FromInt(mode.CalculateBrightness(level.brightnessbelow)); + PixelColor areacolor = PixelColor.Modulate(level.colorbelow, areabrightness); + sectorcolor = areacolor.WithAlpha(255); } // Check if the texture is loaded @@ -169,27 +173,39 @@ namespace CodeImp.DoomBuilder.GZDoomEditing else if(info.Hangs) { // Hang from ceiling - if(Thing.Sector != null) pos.z = Thing.Sector.CeilHeight - info.Height; + if(Thing.Sector != null) + { + SectorData sd = mode.GetSectorData(Thing.Sector); + pos.z = sd.Ceiling.plane.GetZ(Thing.Position) - info.Height; + } + if(Thing.Position.z > 0) pos.z -= Thing.Position.z; // Check if below floor if((Thing.Sector != null) && (pos.z < Thing.Sector.FloorHeight)) { // Put thing on the floor - pos.z = Thing.Sector.FloorHeight; + SectorData sd = mode.GetSectorData(Thing.Sector); + pos.z = sd.Floor.plane.GetZ(Thing.Position); } } else { // Stand on floor - if(Thing.Sector != null) pos.z = Thing.Sector.FloorHeight; + if(Thing.Sector != null) + { + SectorData sd = mode.GetSectorData(Thing.Sector); + pos.z = sd.Floor.plane.GetZ(Thing.Position); + } + if(Thing.Position.z > 0) pos.z += Thing.Position.z; // Check if above ceiling if((Thing.Sector != null) && ((pos.z + info.Height) > Thing.Sector.CeilHeight)) { // Put thing against ceiling - pos.z = Thing.Sector.CeilHeight - info.Height; + SectorData sd = mode.GetSectorData(Thing.Sector); + pos.z = sd.Ceiling.plane.GetZ(Thing.Position) - info.Height; } } diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualCeiling.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualCeiling.cs index c6e51049..6b31a2b7 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualCeiling.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualCeiling.cs @@ -175,9 +175,18 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // This changes the height protected override void ChangeHeight(int amount) { - mode.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, this.Sector.Sector.FixedIndex); - this.Sector.Sector.CeilHeight += amount; - mode.SetActionResult("Changed ceiling height to " + Sector.Sector.CeilHeight + "."); + if(level.sector == Sector.Sector) + { + mode.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, level.sector.FixedIndex); + level.sector.CeilHeight += amount; + mode.SetActionResult("Changed ceiling height to " + level.sector.CeilHeight + "."); + } + else + { + mode.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, level.sector.FixedIndex); + level.sector.FloorHeight += amount; + mode.SetActionResult("Changed floor height to " + level.sector.FloorHeight + "."); + } } // This performs a fast test in object picking @@ -218,15 +227,23 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Return texture name public override string GetTextureName() { - return this.Sector.Sector.CeilTexture; + return level.sector.CeilTexture; } // This changes the texture protected override void SetTexture(string texturename) { - this.Sector.Sector.SetCeilTexture(texturename); + level.sector.SetCeilTexture(texturename); General.Map.Data.UpdateUsedTextures(); - this.Setup(); + if(level.sector == this.Sector.Sector) + { + this.Setup(); + } + else if(mode.VisualSectorExists(level.sector)) + { + BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); + vs.UpdateSectorGeometry(false); + } } #endregion diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs index 10c8bb00..f037c195 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs @@ -162,9 +162,18 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // This changes the height protected override void ChangeHeight(int amount) { - mode.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, this.Sector.Sector.FixedIndex); - this.Sector.Sector.FloorHeight += amount; - mode.SetActionResult("Changed floor height to " + Sector.Sector.FloorHeight + "."); + if(level.sector == Sector.Sector) + { + mode.CreateUndo("Change floor height", UndoGroup.FloorHeightChange, level.sector.FixedIndex); + level.sector.FloorHeight += amount; + mode.SetActionResult("Changed floor height to " + level.sector.FloorHeight + "."); + } + else + { + mode.CreateUndo("Change ceiling height", UndoGroup.CeilingHeightChange, level.sector.FixedIndex); + level.sector.CeilHeight += amount; + mode.SetActionResult("Changed ceiling height to " + level.sector.CeilHeight + "."); + } } // This performs a fast test in object picking @@ -205,15 +214,23 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Return texture name public override string GetTextureName() { - return this.Sector.Sector.FloorTexture; + return level.sector.FloorTexture; } // This changes the texture protected override void SetTexture(string texturename) { - this.Sector.Sector.SetFloorTexture(texturename); + level.sector.SetFloorTexture(texturename); General.Map.Data.UpdateUsedTextures(); - this.Setup(); + if(level.sector == this.Sector.Sector) + { + this.Setup(); + } + else if(mode.VisualSectorExists(level.sector)) + { + BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(level.sector); + vs.UpdateSectorGeometry(false); + } } #endregion diff --git a/Tests/UDMF/udmfexample.wad b/Tests/UDMF/udmfexample.wad index 23d7e4bb..c077371a 100644 Binary files a/Tests/UDMF/udmfexample.wad and b/Tests/UDMF/udmfexample.wad differ