From d6d579ab7691036e43f76dba08d2a76d3e82afb2 Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Sat, 6 Jun 2020 11:51:09 +0200 Subject: [PATCH] Some refactoring Made sloping work more reliably with irregularly shaped sectors --- .../Interface/SlopeArchForm.Designer.cs | 6 ++-- .../BuilderModes/Interface/SlopeArchForm.cs | 9 ++++++ .../BuilderModes/VisualModes/SlopeArcher.cs | 30 ++++++++++++++++--- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Source/Plugins/BuilderModes/Interface/SlopeArchForm.Designer.cs b/Source/Plugins/BuilderModes/Interface/SlopeArchForm.Designer.cs index 8ef8ecac..28fc515d 100644 --- a/Source/Plugins/BuilderModes/Interface/SlopeArchForm.Designer.cs +++ b/Source/Plugins/BuilderModes/Interface/SlopeArchForm.Designer.cs @@ -167,11 +167,11 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(61, 72); + this.label3.Location = new System.Drawing.Point(50, 72); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(37, 13); + this.label3.Size = new System.Drawing.Size(48, 13); this.label3.TabIndex = 27; - this.label3.Text = "Scale:"; + this.label3.Text = "Scale %:"; // // quartercircleleft // diff --git a/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs b/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs index d789eecd..62af830c 100644 --- a/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs +++ b/Source/Plugins/BuilderModes/Interface/SlopeArchForm.cs @@ -121,8 +121,17 @@ namespace CodeImp.DoomBuilder.BuilderModes double t = theta.GetResultFloat(originaltheta); + if (t <= 0.0) + { + t = 1.0; + theta.Text = "1"; + } + if (t > 180.0) + { t = 180.0; + theta.Text = "180"; + } double o = (180 - t) / 2.0; diff --git a/Source/Plugins/BuilderModes/VisualModes/SlopeArcher.cs b/Source/Plugins/BuilderModes/VisualModes/SlopeArcher.cs index e53007df..0aef23a9 100644 --- a/Source/Plugins/BuilderModes/VisualModes/SlopeArcher.cs +++ b/Source/Plugins/BuilderModes/VisualModes/SlopeArcher.cs @@ -27,7 +27,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public double Theta { get { return theta; } set { theta = value; CalculateBaseHeightOffset(); } } public double OffsetAngle { get { return offsetangle; } set { offsetangle = value; CalculateBaseHeightOffset(); } } - public double Scale { get { return scale; } set { scale = value; } } + public double Scale { get { return scale; } set { scale = value; CalculateBaseHeightOffset(); } } public int Baseheight { get { return baseheight; } } public double HeightOffset { get { return heightoffset; } set { heightoffset = value; } } @@ -50,13 +50,12 @@ namespace CodeImp.DoomBuilder.BuilderModes else baseheight = handle1.Level.extrafloor ? handle1.Level.sector.CeilHeight : handle1.Level.sector.FloorHeight; - //baseheight = handle1.Level.type == SectorLevelType.Ceiling ? handle1.Level.sector.CeilHeight : handle1.Level.sector.FloorHeight; baseheightoffset = 0.0; } private void CalculateBaseHeightOffset() { - double right = Math.Cos(0.0); + /* double left = Math.Cos(theta + offsetangle); double middle = Math.Cos(offsetangle); @@ -67,11 +66,11 @@ namespace CodeImp.DoomBuilder.BuilderModes double sectionstart = Math.Cos(offsetangle + theta) * radius; baseheightoffset = Math.Sqrt(radius * radius - sectionstart * sectionstart) * scale; + */ } public void ApplySlope() { - double right = Math.Cos(0.0); double left = Math.Cos(theta + offsetangle); double middle = Math.Cos(offsetangle); @@ -81,11 +80,31 @@ namespace CodeImp.DoomBuilder.BuilderModes double sectionstart = Math.Cos(offsetangle + theta) * radius; + baseheightoffset = Math.Sqrt(radius * radius - sectionstart * sectionstart) * scale; + foreach (BaseVisualGeometrySector bvgs in sectors) { + HashSet vertices = new HashSet(bvgs.Sector.Sides.Count * 2); double u1 = 1.0; double u2 = 0.0; + foreach (Sidedef sd in bvgs.Sector.Sides.Keys) + { + vertices.Add(sd.Line.Start); + vertices.Add(sd.Line.End); + } + + foreach(Vertex v in vertices) + { + double intersection = handleline.GetNearestOnLine(v.Position); + + if (intersection < u1) + u1 = intersection; + if (intersection > u2) + u2 = intersection; + } + + /* foreach (Sidedef sd in bvgs.Sector.Sides.Keys) { double intersection; @@ -99,7 +118,9 @@ namespace CodeImp.DoomBuilder.BuilderModes if (intersection > u2) u2 = intersection; } + */ + /* if (u1 == u2) { if (u1 >= 0.5) @@ -112,6 +133,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } } + */ double xpos1 = sectionstart + (u1 * length); double xpos2 = sectionstart + (u2 * length);