diff --git a/Source/Core/Geometry/InterpolationTools.cs b/Source/Core/Geometry/InterpolationTools.cs
index 86575ba7..0ec8e911 100644
--- a/Source/Core/Geometry/InterpolationTools.cs
+++ b/Source/Core/Geometry/InterpolationTools.cs
@@ -58,22 +58,24 @@ namespace CodeImp.DoomBuilder.Geometry
}
//mxd
- public static int InterpolateColor(PixelColor c1, PixelColor c2, float delta)
+ public static PixelColor InterpolateColor(PixelColor c1, PixelColor c2, float delta)
{
float invdelta = 1.0f - delta;
+ byte a = (byte)(c1.a * invdelta + c2.a * delta);
byte r = (byte)(c1.r * invdelta + c2.r * delta);
byte g = (byte)(c1.g * invdelta + c2.g * delta);
byte b = (byte)(c1.b * invdelta + c2.b * delta);
- return new PixelColor(255, r, g, b).ToInt();
+ return new PixelColor(a, r, g, b);
}
//mxd
- public static int InterpolateColor(PixelColor c1, PixelColor c2, float delta, Mode mode)
+ public static PixelColor InterpolateColor(PixelColor c1, PixelColor c2, float delta, Mode mode)
{
+ byte a = (byte)Math.Round(Interpolate(c1.a, c2.a, delta, mode));
byte r = (byte)Math.Round(Interpolate(c1.r, c2.r, delta, mode));
byte g = (byte)Math.Round(Interpolate(c1.g, c2.g, delta, mode));
byte b = (byte)Math.Round(Interpolate(c1.b, c2.b, delta, mode));
- return new PixelColor(255, r, g, b).ToInt();
+ return new PixelColor(a, r, g, b);
}
}
}
diff --git a/Source/Core/Map/SectorBuilder.cs b/Source/Core/Map/SectorBuilder.cs
index 30f3bb98..0c71693d 100644
--- a/Source/Core/Map/SectorBuilder.cs
+++ b/Source/Core/Map/SectorBuilder.cs
@@ -218,7 +218,7 @@ namespace CodeImp.DoomBuilder.Map
float min_dist = float.MaxValue;
Linedef nearest = null;
- // Go through map lines
+ // Fire a ray east from the vertex and find the first line it crosses
foreach(Linedef line in General.Map.Map.Linedefs)
{
// Ignore if the line is completely left of the vertex
@@ -238,11 +238,23 @@ namespace CodeImp.DoomBuilder.Map
float dist = Math.Abs(int_x - vr_x);
// Check if closest
- if(dist < min_dist)
+ if(nearest == null || dist < min_dist)
{
min_dist = dist;
nearest = line;
}
+ else if(Math.Abs(dist - min_dist) < 0.001f)
+ {
+ // In the case of a tie, use the distance to each line as a tiebreaker - this fixes cases where the ray hits a vertex
+ // shared by two lines. Choosing the further line would mean choosing an inner edge, which is clearly wrong.
+ float line_dist = line.SafeDistanceToSq(vertex_right.Position, true);
+ float nearest_dist = nearest.SafeDistanceToSq(vertex_right.Position, true);
+ if(line_dist < nearest_dist)
+ {
+ min_dist = dist;
+ nearest = line;
+ }
+ }
}
// Check for valid line
@@ -250,8 +262,7 @@ namespace CodeImp.DoomBuilder.Map
// Determine the edge side
float side = -nearest.SideOfLine(vertex_right.Position); //mxd. SideOfLine logic is inverted in Slade 3
- return new LinedefSide(nearest, side > 0); //mxd. The meaning of 0.0 is also inverted!!!
- //mxd. I've spent 2 days figuring this out... :(
+ return new LinedefSide(nearest, side > 0); //mxd. The meaning of 0.0 is also inverted!!! (I've spent 2 days figuring this out...)
}
/// Find the closest edge within the current outline (that isn't part of the current outline)
diff --git a/Source/Core/Map/UniFields.cs b/Source/Core/Map/UniFields.cs
index db94b543..cddb9afe 100644
--- a/Source/Core/Map/UniFields.cs
+++ b/Source/Core/Map/UniFields.cs
@@ -224,11 +224,11 @@ namespace CodeImp.DoomBuilder.Map
public static bool UniValuesMatch(UniValue val1, UniValue val2)
{
if(val1.Type != val2.Type) return false;
- if(val1.Value is int) return (int)val1.Value != (int)val2.Value;
- if(val1.Value is float) return (float)val1.Value != (float)val2.Value;
- if(val1.Value is bool) return (bool)val1.Value != (bool)val2.Value;
- if(val1.Value is string) return (string)val1.Value != (string)val2.Value;
- throw new Exception("Got unknown Custom Field type to compare: " + val1.Value.GetType());
+ if(val1.Value is int) return (int)val1.Value == (int)val2.Value;
+ if(val1.Value is float) return (float)val1.Value == (float)val2.Value;
+ if(val1.Value is bool) return (bool)val1.Value == (bool)val2.Value;
+ if(val1.Value is string) return (string)val1.Value == (string)val2.Value;
+ throw new NotImplementedException("Unknown Custom Field type: " + val1.Value.GetType());
}
/// This compares types and values of given UniFields by key.
diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs
index 985f1467..a096d1d2 100644
--- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs
+++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs
@@ -1935,7 +1935,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
var form = new SelectSimilarElementOptionsPanel();
- if(form.Setup(this)) form.ShowDialog();
+ if(form.Setup(this)) form.ShowDialog(General.Interface);
}
//mxd
diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs
index 4e38c15c..9ac62532 100644
--- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs
+++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs
@@ -2078,7 +2078,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
s.Fields.BeforeFieldsChange();
float u = index / (orderedselection.Count - 1.0f);
- int c = InterpolationTools.InterpolateColor(startcolor, endcolor, u, interpolationmode);
+ int c = InterpolationTools.InterpolateColor(startcolor, endcolor, u, interpolationmode).WithAlpha(0).ToInt(); // No alpha here!
UniFields.SetInteger(s.Fields, key, c, defaultvalue);
s.UpdateNeeded = true;
@@ -2502,7 +2502,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
var form = new SelectSimilarElementOptionsPanel();
- if(form.Setup(this)) form.ShowDialog();
+ if(form.Setup(this)) form.ShowDialog(General.Interface);
}
//mxd
diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs
index 9e572a61..dd0cbf3a 100644
--- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs
+++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs
@@ -1613,7 +1613,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
var form = new SelectSimilarElementOptionsPanel();
- if(form.Setup(this)) form.ShowDialog();
+ if(form.Setup(this)) form.ShowDialog(General.Interface);
}
#endregion
diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs
index 6e72d257..3844d1a3 100644
--- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs
+++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs
@@ -1103,7 +1103,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
var form = new SelectSimilarElementOptionsPanel();
- if(form.Setup(this)) form.ShowDialog();
+ if(form.Setup(this)) form.ShowDialog(General.Interface);
}
#endregion
diff --git a/Source/Plugins/BuilderModes/Interface/SelectSimilarElementOptionsPanel.Designer.cs b/Source/Plugins/BuilderModes/Interface/SelectSimilarElementOptionsPanel.Designer.cs
index e07744b4..864faa0e 100644
--- a/Source/Plugins/BuilderModes/Interface/SelectSimilarElementOptionsPanel.Designer.cs
+++ b/Source/Plugins/BuilderModes/Interface/SelectSimilarElementOptionsPanel.Designer.cs
@@ -228,10 +228,12 @@
this.Controls.Add(this.enableall);
this.Controls.Add(this.apply);
this.Controls.Add(this.cancel);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
- this.MinimumSize = new System.Drawing.Size(300, 200);
+ this.MinimumSize = new System.Drawing.Size(396, 200);
this.Name = "SelectSimilarElementOptionsPanel";
+ this.Opacity = 1;
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
diff --git a/Source/Plugins/BuilderModes/Interface/SelectSimilarElementOptionsPanel.cs b/Source/Plugins/BuilderModes/Interface/SelectSimilarElementOptionsPanel.cs
index ce0522b6..26d22529 100644
--- a/Source/Plugins/BuilderModes/Interface/SelectSimilarElementOptionsPanel.cs
+++ b/Source/Plugins/BuilderModes/Interface/SelectSimilarElementOptionsPanel.cs
@@ -11,7 +11,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
public partial class SelectSimilarElementOptionsPanel : DelayedForm
{
- private static Size size = Size.Empty;
private static Point location = Point.Empty;
private static readonly object[] flags = {
new SectorPropertiesCopySettings(),
@@ -30,10 +29,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
InitializeComponent();
//apply window size and location
- if(!size.IsEmpty && !location.IsEmpty)
+ if(!location.IsEmpty)
{
this.StartPosition = FormStartPosition.Manual;
- this.Size = size;
this.Location = location;
}
@@ -79,6 +77,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//fill flags
showntabs = new List();
+ int maxheight = int.MinValue;
foreach(TabPage page in activetabs)
{
CheckboxArrayControl curControl = page.Controls[0] as CheckboxArrayControl;
@@ -102,9 +101,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
curControl.PositionCheckboxes();
showntabs.Add(page);
+
+ // Store height
+ maxheight = Math.Max(maxheight, curControl.GetHeight());
}
}
+ // Apply height
+ if(maxheight != int.MinValue)
+ {
+ this.Height += maxheight - activetabs[0].Controls[0].Height;
+ }
+
// Got anything to show?
if(showntabs.Count == 0) return SetupFailed("This action doesn't support current editing mode...");
@@ -124,7 +132,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
private void SelectSimilarElementOptionsPanel_FormClosing(object sender, FormClosingEventArgs e)
{
- size = this.Size;
location = this.Location;
}
diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs
index 13241004..73fe4ea7 100644
--- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs
+++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs
@@ -304,7 +304,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
float cz = data.Ceiling.plane.GetZ(v.x, v.y);
float delta = 1.0f - (((v.z - cgz) / (cz - cgz)) * 0.9f);
PixelColor vc = PixelColor.FromInt(v.c);
- v.c = InterpolationTools.InterpolateColor(GetGlowColor(data.CeilingGlow, vc), vc, delta);
+ v.c = InterpolationTools.InterpolateColor(GetGlowColor(data.CeilingGlow, vc), vc, delta).WithAlpha(255).ToInt();
}
}
@@ -319,7 +319,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
float fz = data.Floor.plane.GetZ(v.x, v.y);
float delta = 1.0f - (((v.z - fz) / (fgz - fz)) * 0.9f);
PixelColor vc = PixelColor.FromInt(v.c);
- v.c = InterpolationTools.InterpolateColor(vc, GetGlowColor(data.FloorGlow, vc), delta);
+ v.c = InterpolationTools.InterpolateColor(vc, GetGlowColor(data.FloorGlow, vc), delta).WithAlpha(255).ToInt();
}
}