diff --git a/Build/Configurations/Includes/ZDoom_misc.cfg b/Build/Configurations/Includes/ZDoom_misc.cfg index 7ef70bb7..5abfba55 100644 --- a/Build/Configurations/Includes/ZDoom_misc.cfg +++ b/Build/Configurations/Includes/ZDoom_misc.cfg @@ -1966,3 +1966,25 @@ doormaking_udmf makedoorarg4 = 0; } +//mxd. Ambient sound thing args (because copy-pasting those 66 times is not fun) +ambientsoundthing_args +{ + arg1 + { + title = "Volume"; + type = 11; + enum = "sound_volume"; + } + arg2 + { + title = "Min. Fading Distance"; + } + arg3 + { + title = "Max. Heard Distance"; + } + arg4 + { + title = "Distance Multiplier"; + } +} \ No newline at end of file diff --git a/Build/Configurations/Includes/ZDoom_things.cfg b/Build/Configurations/Includes/ZDoom_things.cfg index cbf355d4..9165e08b 100644 --- a/Build/Configurations/Includes/ZDoom_things.cfg +++ b/Build/Configurations/Includes/ZDoom_things.cfg @@ -118,70 +118,326 @@ zdoom } } - 14001 = "Ambient Sound 01"; - 14002 = "Ambient Sound 02"; - 14003 = "Ambient Sound 03"; - 14004 = "Ambient Sound 04"; - 14005 = "Ambient Sound 05"; - 14006 = "Ambient Sound 06"; - 14007 = "Ambient Sound 07"; - 14008 = "Ambient Sound 08"; - 14009 = "Ambient Sound 09"; - 14010 = "Ambient Sound 10"; - 14011 = "Ambient Sound 11"; - 14012 = "Ambient Sound 12"; - 14013 = "Ambient Sound 13"; - 14014 = "Ambient Sound 14"; - 14015 = "Ambient Sound 15"; - 14016 = "Ambient Sound 16"; - 14017 = "Ambient Sound 17"; - 14018 = "Ambient Sound 18"; - 14019 = "Ambient Sound 19"; - 14020 = "Ambient Sound 20"; - 14021 = "Ambient Sound 21"; - 14022 = "Ambient Sound 22"; - 14023 = "Ambient Sound 23"; - 14024 = "Ambient Sound 24"; - 14025 = "Ambient Sound 25"; - 14026 = "Ambient Sound 26"; - 14027 = "Ambient Sound 27"; - 14028 = "Ambient Sound 28"; - 14029 = "Ambient Sound 29"; - 14030 = "Ambient Sound 30"; - 14031 = "Ambient Sound 31"; - 14032 = "Ambient Sound 32"; - 14033 = "Ambient Sound 33"; - 14034 = "Ambient Sound 34"; - 14035 = "Ambient Sound 35"; - 14036 = "Ambient Sound 36"; - 14037 = "Ambient Sound 37"; - 14038 = "Ambient Sound 38"; - 14039 = "Ambient Sound 39"; - 14040 = "Ambient Sound 40"; - 14041 = "Ambient Sound 41"; - 14042 = "Ambient Sound 42"; - 14043 = "Ambient Sound 43"; - 14044 = "Ambient Sound 44"; - 14045 = "Ambient Sound 45"; - 14046 = "Ambient Sound 46"; - 14047 = "Ambient Sound 47"; - 14048 = "Ambient Sound 48"; - 14049 = "Ambient Sound 49"; - 14050 = "Ambient Sound 50"; - 14051 = "Ambient Sound 51"; - 14052 = "Ambient Sound 52"; - 14053 = "Ambient Sound 53"; - 14054 = "Ambient Sound 54"; - 14055 = "Ambient Sound 55"; - 14056 = "Ambient Sound 56"; - 14057 = "Ambient Sound 57"; - 14058 = "Ambient Sound 58"; - 14059 = "Ambient Sound 59"; - 14060 = "Ambient Sound 60"; - 14061 = "Ambient Sound 61"; - 14062 = "Ambient Sound 62"; - 14063 = "Ambient Sound 63"; - 14064 = "Ambient Sound 64"; + 14001 + { + title = "Ambient Sound 01"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14002 + { + title = "Ambient Sound 02"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14003 + { + title = "Ambient Sound 03"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14004 + { + title = "Ambient Sound 04"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14005 + { + title = "Ambient Sound 05"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14006 + { + title = "Ambient Sound 06"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14007 + { + title = "Ambient Sound 07"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14008 + { + title = "Ambient Sound 08"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14009 + { + title = "Ambient Sound 09"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14010 + { + title = "Ambient Sound 10"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14011 + { + title = "Ambient Sound 11"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14012 + { + title = "Ambient Sound 12"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14013 + { + title = "Ambient Sound 13"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14014 + { + title = "Ambient Sound 14"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14015 + { + title = "Ambient Sound 15"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14016 + { + title = "Ambient Sound 16"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14017 + { + title = "Ambient Sound 17"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14018 + { + title = "Ambient Sound 18"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14019 + { + title = "Ambient Sound 19"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14020 + { + title = "Ambient Sound 20"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14021 + { + title = "Ambient Sound 21"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14022 + { + title = "Ambient Sound 22"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14023 + { + title = "Ambient Sound 23"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14024 + { + title = "Ambient Sound 24"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14025 + { + title = "Ambient Sound 25"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14026 + { + title = "Ambient Sound 26"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14027 + { + title = "Ambient Sound 27"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14028 + { + title = "Ambient Sound 28"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14029 + { + title = "Ambient Sound 29"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14030 + { + title = "Ambient Sound 30"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14031 + { + title = "Ambient Sound 31"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14032 + { + title = "Ambient Sound 32"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14033 + { + title = "Ambient Sound 33"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14034 + { + title = "Ambient Sound 34"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14035 + { + title = "Ambient Sound 35"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14036 + { + title = "Ambient Sound 36"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14037 + { + title = "Ambient Sound 37"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14038 + { + title = "Ambient Sound 38"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14039 + { + title = "Ambient Sound 39"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14040 + { + title = "Ambient Sound 40"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14041 + { + title = "Ambient Sound 41"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14042 + { + title = "Ambient Sound 42"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14043 + { + title = "Ambient Sound 43"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14044 + { + title = "Ambient Sound 44"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14045 + { + title = "Ambient Sound 45"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14046 + { + title = "Ambient Sound 46"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14047 + { + title = "Ambient Sound 47"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14048 + { + title = "Ambient Sound 48"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14049 + { + title = "Ambient Sound 49"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14050 + { + title = "Ambient Sound 50"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14051 + { + title = "Ambient Sound 51"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14052 + { + title = "Ambient Sound 52"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14053 + { + title = "Ambient Sound 53"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14054 + { + title = "Ambient Sound 54"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14055 + { + title = "Ambient Sound 55"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14056 + { + title = "Ambient Sound 56"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14057 + { + title = "Ambient Sound 57"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14058 + { + title = "Ambient Sound 58"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14059 + { + title = "Ambient Sound 59"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14060 + { + title = "Ambient Sound 60"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14061 + { + title = "Ambient Sound 61"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14062 + { + title = "Ambient Sound 62"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14063 + { + title = "Ambient Sound 63"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } + 14064 + { + title = "Ambient Sound 64"; + include("ZDoom_misc.cfg", "ambientsoundthing_args"); + } 14065 { @@ -193,24 +449,7 @@ zdoom type = 11; enum = "ambient_sounds"; } - arg1 - { - title = "Volume"; - type = 11; - enum = "sound_volume"; - } - arg2 - { - title = "Min. Fading Distance"; - } - arg3 - { - title = "Max. Heard Distance"; - } - arg4 - { - title = "Distance Multiplier"; - } + include("ZDoom_misc.cfg", "ambientsoundthing_args"); } 14066 @@ -239,24 +478,7 @@ zdoom type = 11; enum = "ambient_sounds"; } - arg1 - { - title = "Volume"; - type = 11; - enum = "sound_volume"; - } - arg2 - { - title = "Min. Fading Distance"; - } - arg3 - { - title = "Max. Heard Distance"; - } - arg4 - { - title = "Distance Multiplier"; - } + include("ZDoom_misc.cfg", "ambientsoundthing_args"); } 14101 = "Music Changer 01"; diff --git a/Source/Core/Controls/LinedefInfoPanel.cs b/Source/Core/Controls/LinedefInfoPanel.cs index 9ea9a020..4c6cfb25 100644 --- a/Source/Core/Controls/LinedefInfoPanel.cs +++ b/Source/Core/Controls/LinedefInfoPanel.cs @@ -197,10 +197,14 @@ namespace CodeImp.DoomBuilder.Controls peggedness = "None"; // Linedef info +#if DEBUG + infopanel.Text = " Linedef " + l.Index + " (vert. " + l.Start.Index + " - vert. " + l.End.Index + ") "; +#else infopanel.Text = " Linedef " + l.Index + " "; +#endif action.Text = act.ToString(); length.Text = l.Length.ToString("0.##"); - angle.Text = General.ClampAngle(l.AngleDeg) + "\u00B0"; + angle.Text = l.AngleDeg + "\u00B0"; unpegged.Text = peggedness; unpegged.Enabled = (peggedness != "None"); //mxd peglabel.Enabled = (peggedness != "None"); //mxd diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 16a0b79f..0e0c68b8 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -290,11 +290,11 @@ namespace CodeImp.DoomBuilder.Geometry // path we received from FindClosestPath! if(foundv == null) throw new Exception("FAIL!"); - // From the right-most vertex trace outward to the right to - // find the next closest linedef, this is based on the idea that - // all sectors are closed. - Vector2D lineoffset = new Vector2D(100.0f, 0.0f); - Line2D testline = new Line2D(foundv.Position, foundv.Position + lineoffset); + // From the right-most vertex trace outward to the right to find the next closest linedef, + // this is based on the idea that all sectors are closed. + + //mxd. Intersection test is bounded, so extend end position x to the right map boundary + Line2D testline = new Line2D(foundv.Position, new Vector2D(General.Map.Config.RightBoundary, foundv.Position.y)); scanline = null; float foundu = float.MaxValue; @@ -313,10 +313,25 @@ namespace CodeImp.DoomBuilder.Geometry // Check if this linedef intersects our test line at a closer range float thisu; ld.Line.GetIntersection(testline, out thisu); - if((thisu > 0.00001f) && (thisu < foundu) && !float.IsNaN(thisu)) + if(!float.IsNaN(thisu) && (thisu > 0.00001f)) { - scanline = ld; - foundu = thisu; + if(thisu < foundu) + { + scanline = ld; + foundu = thisu; + } + //mxd. Special cases: when foundv.y matches ld's start or end y, + // prefer the line, which is clser to being parallel to the x axis + else if(scanline != null && Math.Round(thisu, 4) == Math.Round(foundu, 4)) + { + float ldanglerel, scanlineanglerel; + if(GetRelativeAngle(ld, foundv.Position, out ldanglerel) + && GetRelativeAngle(scanline, foundv.Position, out scanlineanglerel) + && (ldanglerel < scanlineanglerel)) + { + scanline = ld; // foundu already matches + } + } } } } @@ -344,6 +359,26 @@ namespace CodeImp.DoomBuilder.Geometry while(true); } + //mxd. Gets angle between pos and l when pos.y matches l.Start.Position.y or l.End.Position.y + private static bool GetRelativeAngle(Linedef l, Vector2D pos, out float result) + { + if(l.Start.Position.y == pos.y) + { + result = Angle2D.GetAngle(pos, l.Start.Position, l.End.Position); + return true; + } + + if(l.End.Position.y == pos.y) + { + result = Angle2D.GetAngle(pos, l.End.Position, l.Start.Position); + return true; + } + + // We just don't know... + result = float.MaxValue; + return false; + } + /// /// This finds the closest path from the beginning of a line to the end of the line. /// When turnatends is true, the algorithm will continue at the other side of the diff --git a/Source/Core/Geometry/Vector2D.cs b/Source/Core/Geometry/Vector2D.cs index ecbb5298..f9279056 100644 --- a/Source/Core/Geometry/Vector2D.cs +++ b/Source/Core/Geometry/Vector2D.cs @@ -257,8 +257,10 @@ namespace CodeImp.DoomBuilder.Geometry // This calculates the angle public float GetAngle() { - // Calculate and return the angle - return -(float)Math.Atan2(-y, x) + Angle2D.PIHALF; //mxd + //mxd. Let's make sure the angle is in [0 .. PI2] range... + float angle = -(float)Math.Atan2(-y, x) + Angle2D.PIHALF; + if(angle < 0f) angle += Angle2D.PI2; + return angle; } // This calculates the length diff --git a/Source/Plugins/BuilderModes/ClassicModes/MakeSectorMode.cs b/Source/Plugins/BuilderModes/ClassicModes/MakeSectorMode.cs index 79455c2a..0130faf4 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/MakeSectorMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/MakeSectorMode.cs @@ -178,17 +178,16 @@ namespace CodeImp.DoomBuilder.BuilderModes Linedef nl = General.Map.Map.NearestLinedef(mousemappos); if(nl != null) { - float side = nl.SideOfLine(mousemappos); - LinedefSide newnearest = new LinedefSide(nl, (side <= 0.0f)); + bool front = (nl.SideOfLine(mousemappos) <= 0.0f); //mxd + LinedefSide newnearest = new LinedefSide(nl, front); if(newnearest != nearestside) { // Only change when buttons are not pressed if(!buttonspressed || (editside == newnearest)) { // Find new sector - General.Interface.SetCursor(Cursors.AppStarting); nearestside = newnearest; - allsides = Tools.FindPotentialSectorAt(mousemappos); + allsides = Tools.FindPotentialSectorAt(nl, front); //mxd if(allsides != null) { alllines = new List(allsides.Count); @@ -198,7 +197,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { alllines = null; } - General.Interface.SetCursor(Cursors.Default); } else { @@ -456,10 +454,10 @@ namespace CodeImp.DoomBuilder.BuilderModes public override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); - if(panning) return; //mxd. Skip all this jass while panning + if(panning) return; //mxd. Skip all this jazz while panning // Highlight the region - Highlight((e.Button != MouseButtons.None)); + Highlight(e.Button != MouseButtons.None); } // Mouse leaves @@ -530,5 +528,4 @@ namespace CodeImp.DoomBuilder.BuilderModes #endregion } -} - +} \ No newline at end of file diff --git a/Source/Plugins/BuilderModes/General/LineLengthLabel.cs b/Source/Plugins/BuilderModes/General/LineLengthLabel.cs index 4c420fdc..f35936b7 100644 --- a/Source/Plugins/BuilderModes/General/LineLengthLabel.cs +++ b/Source/Plugins/BuilderModes/General/LineLengthLabel.cs @@ -128,7 +128,7 @@ namespace CodeImp.DoomBuilder.BuilderModes float length = delta.GetLength(); if(showangle) { - int displayangle = General.ClampAngle((int)Math.Round(Angle2D.RadToDeg(delta.GetAngle()))); + int displayangle = (int)Math.Round(Angle2D.RadToDeg(delta.GetAngle())); label.Text = "L:" + length.ToString(VALUE_FORMAT) + "; A:" + displayangle; } else