From 073798166a497e75f327c6882c47d14ada29fb29 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 10 Jun 2023 03:00:20 +0200 Subject: [PATCH 1/3] Implement absolutez flag for things --- Build/Configurations/Includes/SRB222_misc.cfg | 2 ++ Source/Core/Controls/ThingInfoPanel.cs | 2 +- Source/Core/Geometry/Tools.cs | 6 +++--- Source/Plugins/BuilderModes/General/BuilderModesTools.cs | 6 +++--- Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Build/Configurations/Includes/SRB222_misc.cfg b/Build/Configurations/Includes/SRB222_misc.cfg index 61b79ae5..e274fece 100644 --- a/Build/Configurations/Includes/SRB222_misc.cfg +++ b/Build/Configurations/Includes/SRB222_misc.cfg @@ -126,6 +126,7 @@ sectorflagscategories thingflags_udmf { flip = "Flip"; + absolutez = "Absolute Z height"; } // Thing flags UDMF translation table @@ -137,6 +138,7 @@ thingflagstranslation 2 = "flip"; 4 = "special"; 8 = "ambush"; + 16 = "absolutez"; } // DEFAULT SECTOR BRIGHTNESS LEVELS diff --git a/Source/Core/Controls/ThingInfoPanel.cs b/Source/Core/Controls/ThingInfoPanel.cs index 6ec78d70..cd426b1a 100644 --- a/Source/Core/Controls/ThingInfoPanel.cs +++ b/Source/Core/Controls/ThingInfoPanel.cs @@ -87,7 +87,7 @@ namespace CodeImp.DoomBuilder.Controls // Determine z info to show t.DetermineSector(); string zinfo; - if(ti.AbsoluteZ || t.Sector == null) + if(ti.AbsoluteZ || t.IsFlagSet(General.Map.UDMF ? "absolutez" : "16") || t.Sector == null) { zinfo = t.Position.z.ToString(CultureInfo.InvariantCulture) + " (abs.)"; //mxd } diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 99caff56..f049175b 100755 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -2213,7 +2213,7 @@ namespace CodeImp.DoomBuilder.Geometry if(initialSector != t.Sector && General.Map.FormatInterface.HasThingHeight) { ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type); - if(ti.AbsoluteZ) return; + if(ti.AbsoluteZ || t.IsFlagSet(General.Map.UDMF ? "absolutez" : "16")) return; if(ti.Hangs && initialSector.CeilHeight != t.Sector.CeilHeight) { @@ -2226,10 +2226,10 @@ namespace CodeImp.DoomBuilder.Geometry } } - public static int GetThingAbsoluteZ(Thing t, ThingTypeInfo ti) + public static int GetThingAbsoluteZ(Thing t, ThingTypeInfo ti) { // Determine z info - if(ti.AbsoluteZ) return (int)t.Position.z; + if(ti.AbsoluteZ || t.IsFlagSet(General.Map.UDMF ? "absolutez" : "16")) return (int)t.Position.z; if(t.Sector != null) { diff --git a/Source/Plugins/BuilderModes/General/BuilderModesTools.cs b/Source/Plugins/BuilderModes/General/BuilderModesTools.cs index a42bb112..5d5d8e6c 100755 --- a/Source/Plugins/BuilderModes/General/BuilderModesTools.cs +++ b/Source/Plugins/BuilderModes/General/BuilderModesTools.cs @@ -354,7 +354,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { Vector3D pos = thing.Thing.Position; double thingheight = thing.Thing.Height; - bool absolute = thing.Info.AbsoluteZ; + bool absolute = thing.Info.AbsoluteZ || thing.Thing.IsFlagSet(General.Map.UDMF ? "absolutez" : "16"); bool hangs = thing.Info.Hangs; if(absolute && hangs) @@ -450,7 +450,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { Vector3D pos = thing.Thing.Position; double thingheight = thing.Thing.Height; - bool absolute = thing.Info.AbsoluteZ; + bool absolute = thing.Info.AbsoluteZ || thing.Thing.IsFlagSet(General.Map.UDMF ? "absolutez" : "16"); ; bool hangs = thing.Info.Hangs; if(absolute && hangs) @@ -577,7 +577,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(info != null) { if(info.AbsoluteZ && info.Hangs) return t.Position.z; // Not sure what to do here... - if(info.AbsoluteZ) + if(info.AbsoluteZ || t.IsFlagSet(General.Map.UDMF ? "absolutez" : "16")) { // Transform to floor-aligned position SectorData nsd = mode.GetSectorData(t.Sector); diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index 28a29469..f9987579 100755 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -434,7 +434,7 @@ namespace CodeImp.DoomBuilder.BuilderModes pos.z = (Thing.Args[0] == 0) ? sd.Floor.sector.FloorHeight + Thing.Position.z : Thing.Position.z; } } - else if(info.AbsoluteZ) + else if(info.AbsoluteZ || Thing.IsFlagSet(General.Map.UDMF ? "absolutez" : "16")) { // Absolute Z position pos.z = Thing.Position.z; From 606f323cac771f83135b9f74dbe6b7a849cfc361 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 10 Jun 2023 16:08:38 +0200 Subject: [PATCH 2/3] Support Flip flag, add properties for flip & absolutez flags --- Source/Core/Controls/ThingInfoPanel.cs | 6 +-- Source/Core/Geometry/Tools.cs | 12 +++--- Source/Core/Map/Thing.cs | 18 +++++++-- .../BuilderModes/General/BuilderModesTools.cs | 14 +++---- .../VisualModes/BaseVisualThing.cs | 40 +++++++++++-------- 5 files changed, 53 insertions(+), 37 deletions(-) diff --git a/Source/Core/Controls/ThingInfoPanel.cs b/Source/Core/Controls/ThingInfoPanel.cs index cd426b1a..298ad5ff 100644 --- a/Source/Core/Controls/ThingInfoPanel.cs +++ b/Source/Core/Controls/ThingInfoPanel.cs @@ -87,14 +87,14 @@ namespace CodeImp.DoomBuilder.Controls // Determine z info to show t.DetermineSector(); string zinfo; - if(ti.AbsoluteZ || t.IsFlagSet(General.Map.UDMF ? "absolutez" : "16") || t.Sector == null) + if(ti.AbsoluteZ || t.AbsoluteZ || t.Sector == null) { zinfo = t.Position.z.ToString(CultureInfo.InvariantCulture) + " (abs.)"; //mxd } else { - // Hangs from ceiling? - if(ti.Hangs) + // Hangs from ceiling? / Is flipped? + if(t.IsFlipped) zinfo = t.Position.z + " (" + Math.Round(Sector.GetCeilingPlane(t.Sector).GetZ(t.Position) - t.Position.z - ti.Height, General.Map.FormatInterface.VertexDecimals).ToString(CultureInfo.InvariantCulture) + ")"; //mxd else zinfo = t.Position.z + " (" + Math.Round(Sector.GetFloorPlane(t.Sector).GetZ(t.Position) + t.Position.z, General.Map.FormatInterface.VertexDecimals).ToString(CultureInfo.InvariantCulture) + ")"; //mxd diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index f049175b..c4b24f96 100755 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -2164,7 +2164,7 @@ namespace CodeImp.DoomBuilder.Geometry ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type); int absz = GetThingAbsoluteZ(t, ti); int height = ti.Height == 0 ? 1 : (int)ti.Height; - Rectangle thing = new Rectangle(0, ti.Hangs ? absz - height : absz, 1, height); + Rectangle thing = new Rectangle(0, t.IsFlipped ? absz - height : absz, 1, height); if(front.FloorHeight < back.FloorHeight) { @@ -2213,9 +2213,9 @@ namespace CodeImp.DoomBuilder.Geometry if(initialSector != t.Sector && General.Map.FormatInterface.HasThingHeight) { ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type); - if(ti.AbsoluteZ || t.IsFlagSet(General.Map.UDMF ? "absolutez" : "16")) return; + if(ti.AbsoluteZ || t.AbsoluteZ) return; - if(ti.Hangs && initialSector.CeilHeight != t.Sector.CeilHeight) + if(t.IsFlipped && initialSector.CeilHeight != t.Sector.CeilHeight) { t.Move(t.Position.x, t.Position.y, t.Position.z - (initialSector.CeilHeight - t.Sector.CeilHeight)); return; @@ -2229,12 +2229,12 @@ namespace CodeImp.DoomBuilder.Geometry public static int GetThingAbsoluteZ(Thing t, ThingTypeInfo ti) { // Determine z info - if(ti.AbsoluteZ || t.IsFlagSet(General.Map.UDMF ? "absolutez" : "16")) return (int)t.Position.z; + if(ti.AbsoluteZ || t.AbsoluteZ) return (int)t.Position.z; if(t.Sector != null) { - // Hangs from ceiling? - if(ti.Hangs) return (int)(t.Sector.CeilHeight - t.Position.z - ti.Height); + // Hangs from ceiling? / is flipped? + if(t.IsFlipped) return (int)(t.Sector.CeilHeight - t.Position.z - ti.Height); return (int)(t.Sector.FloorHeight + t.Position.z); } diff --git a/Source/Core/Map/Thing.cs b/Source/Core/Map/Thing.cs index ece6f20e..130a761a 100755 --- a/Source/Core/Map/Thing.cs +++ b/Source/Core/Map/Thing.cs @@ -124,13 +124,23 @@ namespace CodeImp.DoomBuilder.Map public bool IsDirectional { get { return directional; } } //mxd public bool Highlighted { get { return highlighted; } set { highlighted = value; } } //mxd internal int LastProcessed { get { return lastProcessed; } set { lastProcessed = value; } } + public bool Flip { get { return General.Map.UDMF && IsFlagSet("flip"); } } + public bool AbsoluteZ { get { return General.Map.UDMF && IsFlagSet("absolutez"); } } + public bool IsFlipped + { + get + { + ThingTypeInfo ti = General.Map.Data.GetThingInfo(Type); + return ti.Hangs ^ Flip; + } + } - #endregion + #endregion - #region ================== Constructor / Disposer + #region ================== Constructor / Disposer - // Constructor - internal Thing(MapSet map, int listindex, bool recordundo = true) + // Constructor + internal Thing(MapSet map, int listindex, bool recordundo = true) { // Initialize this.elementtype = MapElementType.THING; //mxd diff --git a/Source/Plugins/BuilderModes/General/BuilderModesTools.cs b/Source/Plugins/BuilderModes/General/BuilderModesTools.cs index 5d5d8e6c..434aa31f 100755 --- a/Source/Plugins/BuilderModes/General/BuilderModesTools.cs +++ b/Source/Plugins/BuilderModes/General/BuilderModesTools.cs @@ -354,8 +354,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { Vector3D pos = thing.Thing.Position; double thingheight = thing.Thing.Height; - bool absolute = thing.Info.AbsoluteZ || thing.Thing.IsFlagSet(General.Map.UDMF ? "absolutez" : "16"); - bool hangs = thing.Info.Hangs; + bool absolute = thing.Info.AbsoluteZ || thing.Thing.AbsoluteZ; + bool hangs = thing.Thing.IsFlipped; if(absolute && hangs) { @@ -450,8 +450,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { Vector3D pos = thing.Thing.Position; double thingheight = thing.Thing.Height; - bool absolute = thing.Info.AbsoluteZ || thing.Thing.IsFlagSet(General.Map.UDMF ? "absolutez" : "16"); ; - bool hangs = thing.Info.Hangs; + bool absolute = thing.Info.AbsoluteZ || thing.Thing.AbsoluteZ; ; + bool hangs = thing.Thing.IsFlipped; if(absolute && hangs) { @@ -576,15 +576,15 @@ namespace CodeImp.DoomBuilder.BuilderModes ThingTypeInfo info = General.Map.Data.GetThingInfoEx(t.Type); if(info != null) { - if(info.AbsoluteZ && info.Hangs) return t.Position.z; // Not sure what to do here... - if(info.AbsoluteZ || t.IsFlagSet(General.Map.UDMF ? "absolutez" : "16")) + if(info.AbsoluteZ && t.IsFlipped) return t.Position.z; // Not sure what to do here... + if(info.AbsoluteZ || t.AbsoluteZ) { // Transform to floor-aligned position SectorData nsd = mode.GetSectorData(t.Sector); return t.Position.z - nsd.Floor.plane.GetZ(t.Position) + t.Height; } - if(info.Hangs) + if(t.IsFlipped) { // Transform to floor-aligned position. Align top of target thing to the bottom of the hanging thing SectorData nsd = mode.GetSectorData(t.Sector); diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index f9987579..2c9ef2d9 100755 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -216,7 +216,8 @@ namespace CodeImp.DoomBuilder.BuilderModes if(!info.Bright) { - Vector3D thingpos = new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position)); + double thingz = Thing.IsFlipped ? sd.Ceiling.plane.GetZ(Thing.Position) - Thing.Position.z - Thing.Height : Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position); + Vector3D thingpos = new Vector3D(Thing.Position.x, Thing.Position.y, thingz); SectorLevel level = sd.GetLevelAboveOrAt(thingpos); //mxd. Let's use point on floor plane instead of Thing.Sector.FloorHeight; @@ -290,7 +291,8 @@ namespace CodeImp.DoomBuilder.BuilderModes //TECH: even Bright Thing frames are affected by custom fade... else { - Vector3D thingpos = new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position)); + double thingz = Thing.IsFlipped ? sd.Ceiling.plane.GetZ(Thing.Position) - Thing.Position.z - Thing.Height : Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position); + Vector3D thingpos = new Vector3D(Thing.Position.x, Thing.Position.y, thingz); SectorLevel level = sd.GetLevelAboveOrAt(thingpos); if(level != null && level.sector.FogMode > SectorFogMode.CLASSIC) @@ -342,35 +344,37 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Sprite mirroring float ul = (info.SpriteFrame[i].Mirror ? 1f : 0f); float ur = (info.SpriteFrame[i].Mirror ? 0f : 1f); + float vb = (Thing.Flip ? 1f : 0f); + float vt = (Thing.Flip ? 0f : 1f); if(sizeless) //mxd { float hh = height / 2; - verts[0] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(offsets.y - hh), sectorcolor, ul, 1.0f); - verts[1] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(hh + offsets.y), sectorcolor, ul, 0.0f); - verts[2] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(hh + offsets.y), sectorcolor, ur, 0.0f); + verts[0] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(offsets.y - hh), sectorcolor, ul, vt); + verts[1] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(hh + offsets.y), sectorcolor, ul, vb); + verts[2] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(hh + offsets.y), sectorcolor, ur, vb); verts[3] = verts[0]; verts[4] = verts[2]; - verts[5] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(offsets.y - hh), sectorcolor, ur, 1.0f); + verts[5] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(offsets.y - hh), sectorcolor, ur, vt); } else if (info.CenterHitbox) { float hh = height / 2; - verts[0] = new WorldVertex((float)(-radius + offsets.x), 0.0f, -hh, sectorcolor, 0.0f, 1.0f); - verts[1] = new WorldVertex((float)(-radius + offsets.x), 0.0f, hh, sectorcolor, 0.0f, 0.0f); - verts[2] = new WorldVertex((float)(+radius + offsets.x), 0.0f, hh, sectorcolor, 1.0f, 0.0f); + verts[0] = new WorldVertex((float)(-radius + offsets.x), 0.0f, -hh, sectorcolor, 0.0f, vt); + verts[1] = new WorldVertex((float)(-radius + offsets.x), 0.0f, hh, sectorcolor, 0.0f, vb); + verts[2] = new WorldVertex((float)(+radius + offsets.x), 0.0f, hh, sectorcolor, 1.0f, vb); verts[3] = verts[0]; verts[4] = verts[2]; - verts[5] = new WorldVertex((float)(+radius + offsets.x), 0.0f, -hh, sectorcolor, 1.0f, 1.0f); + verts[5] = new WorldVertex((float)(+radius + offsets.x), 0.0f, -hh, sectorcolor, 1.0f, vt); } else { - verts[0] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)offsets.y, sectorcolor, ul, 1.0f); - verts[1] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(height + offsets.y), sectorcolor, ul, 0.0f); - verts[2] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(height + offsets.y), sectorcolor, ur, 0.0f); + verts[0] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)offsets.y, sectorcolor, ul, vt); + verts[1] = new WorldVertex((float)(-radius + offsets.x), 0.0f, (float)(height + offsets.y), sectorcolor, ul, vb); + verts[2] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)(height + offsets.y), sectorcolor, ur, vb); verts[3] = verts[0]; verts[4] = verts[2]; - verts[5] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)offsets.y, sectorcolor, ur, 1.0f); + verts[5] = new WorldVertex((float)(+radius + offsets.x), 0.0f, (float)offsets.y, sectorcolor, ur, vt); } allverts[i] = verts; } @@ -434,12 +438,12 @@ namespace CodeImp.DoomBuilder.BuilderModes pos.z = (Thing.Args[0] == 0) ? sd.Floor.sector.FloorHeight + Thing.Position.z : Thing.Position.z; } } - else if(info.AbsoluteZ || Thing.IsFlagSet(General.Map.UDMF ? "absolutez" : "16")) + else if(info.AbsoluteZ || Thing.AbsoluteZ) { // Absolute Z position pos.z = Thing.Position.z; } - else if(info.Hangs) + else if(Thing.IsFlipped) // info.Hangs { // Hang from ceiling if(Thing.Sector != null) @@ -477,6 +481,8 @@ namespace CodeImp.DoomBuilder.BuilderModes } } } + + //if (info.ZOffset != 0) pos.z += Thing.IsFlipped ? -info.ZOffset : info.ZOffset; // Apply settings SetPosition(pos); @@ -817,7 +823,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) undoticket = mode.CreateUndo("Change thing height"); - Thing.Move(Thing.Position + new Vector3D(0.0f, 0.0f, (info.Hangs ? -amount : amount))); + Thing.Move(Thing.Position + new Vector3D(0.0f, 0.0f, (Thing.IsFlipped ? -amount : amount))); mode.SetActionResult("Changed thing height to " + Thing.Position.z + "."); From b5cfc3da4b4ca594a0c845b9e14c0d8f3f776a17 Mon Sep 17 00:00:00 2001 From: spherallic Date: Sat, 10 Jun 2023 17:40:24 +0200 Subject: [PATCH 3/3] Update thing Z whenever "Absolute Z Height" flag is (un)checked --- Source/Core/Windows/ThingEditFormSRB2.cs | 39 +++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/Source/Core/Windows/ThingEditFormSRB2.cs b/Source/Core/Windows/ThingEditFormSRB2.cs index 88260fcc..6f2b13d7 100644 --- a/Source/Core/Windows/ThingEditFormSRB2.cs +++ b/Source/Core/Windows/ThingEditFormSRB2.cs @@ -173,14 +173,15 @@ namespace CodeImp.DoomBuilder.Windows // Coordination angle.Text = ft.AngleDoom.ToString(); - cbAbsoluteHeight.Checked = useabsoluteheight; //mxd + cbAbsoluteHeight.Checked = useabsoluteheight || ft.AbsoluteZ; //mxd + cbAbsoluteHeight.Enabled = !ft.AbsoluteZ; //mxd ft.DetermineSector(); double floorheight = (ft.Sector != null ? Sector.GetFloorPlane(ft.Sector).GetZ(ft.Position) : 0); posX.Text = (ft.Position.x).ToString(); posY.Text = (ft.Position.y).ToString(); - posZ.Text = (useabsoluteheight ? (Math.Round(ft.Position.z + floorheight, General.Map.FormatInterface.VertexDecimals)).ToString() : (ft.Position.z).ToString()); + posZ.Text = ((useabsoluteheight && !ft.AbsoluteZ) ? (Math.Round(ft.Position.z + floorheight, General.Map.FormatInterface.VertexDecimals)).ToString() : (ft.Position.z).ToString()); posX.ButtonStep = General.Map.Grid.GridSize; posY.ButtonStep = General.Map.Grid.GridSize; posZ.ButtonStep = General.Map.Grid.GridSize; @@ -249,7 +250,7 @@ namespace CodeImp.DoomBuilder.Windows //mxd. Position if((t.Position.x).ToString() != posX.Text) posX.Text = ""; if((t.Position.y).ToString() != posY.Text) posY.Text = ""; - if(useabsoluteheight && t.Sector != null) + if(useabsoluteheight && !t.AbsoluteZ && t.Sector != null) { if((Math.Round(Sector.GetFloorPlane(t.Sector).GetZ(t.Position) + t.Position.z, General.Map.FormatInterface.VertexDecimals)).ToString() != posZ.Text) posZ.Text = ""; @@ -547,13 +548,13 @@ namespace CodeImp.DoomBuilder.Windows //update label text Thing ft = General.GetByIndex(things, 0); double z = ft.Position.z; - if(useabsoluteheight && ft.Sector != null) z += Sector.GetFloorPlane(ft.Sector).GetZ(ft.Position); + if(useabsoluteheight && !ft.AbsoluteZ && ft.Sector != null) z += Sector.GetFloorPlane(ft.Sector).GetZ(ft.Position); posZ.Text = Math.Round(z, General.Map.FormatInterface.VertexDecimals).ToString(); foreach(Thing t in things) { z = t.Position.z; - if(useabsoluteheight && t.Sector != null) z += Sector.GetFloorPlane(t.Sector).GetZ(t.Position); + if(useabsoluteheight && !ft.AbsoluteZ && t.Sector != null) z += Sector.GetFloorPlane(t.Sector).GetZ(t.Position); string ztext = Math.Round(z, General.Map.FormatInterface.VertexDecimals).ToString(); if(posZ.Text != ztext) { @@ -656,7 +657,7 @@ namespace CodeImp.DoomBuilder.Windows foreach(Thing t in things) { double z = posZ.GetResultFloat(thingprops[i++].Z); - if(useabsoluteheight && !posZ.CheckIsRelative() && t.Sector != null) + if(useabsoluteheight && !t.AbsoluteZ && !posZ.CheckIsRelative() && t.Sector != null) z -= Math.Round(Sector.GetFloorPlane(t.Sector).GetZ(t.Position.x, t.Position.y), General.Map.FormatInterface.VertexDecimals); t.Move(new Vector3D(t.Position.x, t.Position.y, z)); } @@ -839,6 +840,31 @@ namespace CodeImp.DoomBuilder.Windows return; } + preventchanges = true; + + // Update Z height, in case AbsoluteZ flag changed + Thing ft = General.GetByIndex(things, 0); + double z = ft.Position.z; + if (useabsoluteheight && !ft.AbsoluteZ && ft.Sector != null) z += Sector.GetFloorPlane(ft.Sector).GetZ(ft.Position); + posZ.Text = Math.Round(z, General.Map.FormatInterface.VertexDecimals).ToString(); + + foreach (Thing t in things) + { + z = t.Position.z; + if (useabsoluteheight && !ft.AbsoluteZ && t.Sector != null) z += Sector.GetFloorPlane(t.Sector).GetZ(t.Position); + string ztext = Math.Round(z, General.Map.FormatInterface.VertexDecimals).ToString(); + if (posZ.Text != ztext) + { + posZ.Text = ""; + break; + } + } + + cbAbsoluteHeight.Checked = useabsoluteheight || ft.AbsoluteZ; //mxd + cbAbsoluteHeight.Enabled = !ft.AbsoluteZ; + + preventchanges = false; + // Everything is OK missingflags.Visible = false; settingsgroup.ForeColor = SystemColors.ControlText; @@ -873,6 +899,5 @@ namespace CodeImp.DoomBuilder.Windows { } - } } \ No newline at end of file