Added option for special handling of triangular sectors when doing visual sloping. When enabled it'll always select an opposite smart pivot handle. Enabled by default, can be disabled in Tools -> Preferences -> Editing -> Opposite side/vertex is smart pivot handle on triangular sectors

This commit is contained in:
biwa 2021-02-13 12:03:37 +01:00
parent b70970ebcf
commit 3c7811de5e
6 changed files with 126 additions and 58 deletions

View file

@ -141,6 +141,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
private int eventlinelabelvisibility; // 0 = never show, 1 = forward only, 2 = reverse only, 3 = forward + reverse
private int eventlinelabelstyle; // 0 = Action only, 1 = Action + short arguments, 2 = action + full arguments
private bool eventlinedistinctcolors;
private bool useoppositesmartpivothandle;
#endregion
@ -199,6 +200,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public int EventLineLabelVisibility { get { return eventlinelabelvisibility; } internal set { eventlinelabelvisibility = value; } }
public int EventLineLabelStyle { get { return eventlinelabelstyle; } internal set { eventlinelabelstyle = value; } }
public bool EventLineDistinctColors { get { return eventlinedistinctcolors; } internal set { eventlinedistinctcolors = value; } }
public bool UseOppositeSmartPivotHandle { get { return useoppositesmartpivothandle; } internal set { useoppositesmartpivothandle = value; } }
//mxd. "Make Door" action persistent settings
internal MakeDoorSettings MakeDoor;
@ -306,6 +308,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
eventlinelabelvisibility = General.Settings.ReadPluginSetting("eventlinelabelvisibility", 3);
eventlinelabelstyle = General.Settings.ReadPluginSetting("eventlinelabelstyle", 2);
eventlinedistinctcolors = General.Settings.ReadPluginSetting("eventlinedistinctcolors", true);
useoppositesmartpivothandle = General.Settings.ReadPluginSetting("useoppositesmartpivothandle", true);
}
//mxd. Load settings, which can be changed via UI

View file

@ -30,6 +30,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
this.tabs = new System.Windows.Forms.TabControl();
this.taboptions = new System.Windows.Forms.TabPage();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.eventlinelabelstyle = new System.Windows.Forms.ComboBox();
this.eventlinelabelvisibility = new System.Windows.Forms.ComboBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.label15 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
@ -75,16 +78,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.label10 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.heightbysidedef = new System.Windows.Forms.ComboBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.eventlinelabelvisibility = new System.Windows.Forms.ComboBox();
this.eventlinelabelstyle = new System.Windows.Forms.ComboBox();
this.useoppositesmartpivothandle = new System.Windows.Forms.CheckBox();
this.tabs.SuspendLayout();
this.taboptions.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox5.SuspendLayout();
this.SuspendLayout();
//
// tabs
@ -117,6 +118,44 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.taboptions.Text = "Editing";
this.taboptions.UseVisualStyleBackColor = true;
//
// groupBox5
//
this.groupBox5.Controls.Add(this.eventlinelabelstyle);
this.groupBox5.Controls.Add(this.eventlinelabelvisibility);
this.groupBox5.Location = new System.Drawing.Point(6, 445);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(272, 54);
this.groupBox5.TabIndex = 4;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Event line labels";
//
// eventlinelabelstyle
//
this.eventlinelabelstyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.eventlinelabelstyle.FormattingEnabled = true;
this.eventlinelabelstyle.Items.AddRange(new object[] {
"Action only",
"Action + short arguments",
"Action + full arguments"});
this.eventlinelabelstyle.Location = new System.Drawing.Point(133, 19);
this.eventlinelabelstyle.Name = "eventlinelabelstyle";
this.eventlinelabelstyle.Size = new System.Drawing.Size(133, 21);
this.eventlinelabelstyle.TabIndex = 1;
//
// eventlinelabelvisibility
//
this.eventlinelabelvisibility.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.eventlinelabelvisibility.FormattingEnabled = true;
this.eventlinelabelvisibility.Items.AddRange(new object[] {
"Never show",
"Forward only",
"Reverse only",
"Forward + Reverse"});
this.eventlinelabelvisibility.Location = new System.Drawing.Point(6, 19);
this.eventlinelabelvisibility.Name = "eventlinelabelvisibility";
this.eventlinelabelvisibility.Size = new System.Drawing.Size(121, 21);
this.eventlinelabelvisibility.TabIndex = 0;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label15);
@ -235,6 +274,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//
// groupBox3
//
this.groupBox3.Controls.Add(this.useoppositesmartpivothandle);
this.groupBox3.Controls.Add(this.additivepaintselect);
this.groupBox3.Controls.Add(this.switchviewmodes);
this.groupBox3.Controls.Add(this.autodrawonedit);
@ -670,43 +710,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.heightbysidedef.Size = new System.Drawing.Size(309, 21);
this.heightbysidedef.TabIndex = 0;
//
// groupBox5
// useoppositesmartpivothandle
//
this.groupBox5.Controls.Add(this.eventlinelabelstyle);
this.groupBox5.Controls.Add(this.eventlinelabelvisibility);
this.groupBox5.Location = new System.Drawing.Point(6, 445);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(272, 54);
this.groupBox5.TabIndex = 4;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Event line labels";
//
// eventlinelabelvisibility
//
this.eventlinelabelvisibility.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.eventlinelabelvisibility.FormattingEnabled = true;
this.eventlinelabelvisibility.Items.AddRange(new object[] {
"Never show",
"Forward only",
"Reverse only",
"Forward + Reverse"});
this.eventlinelabelvisibility.Location = new System.Drawing.Point(6, 19);
this.eventlinelabelvisibility.Name = "eventlinelabelvisibility";
this.eventlinelabelvisibility.Size = new System.Drawing.Size(121, 21);
this.eventlinelabelvisibility.TabIndex = 0;
//
// eventlinelabelstyle
//
this.eventlinelabelstyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.eventlinelabelstyle.FormattingEnabled = true;
this.eventlinelabelstyle.Items.AddRange(new object[] {
"Action only",
"Action + short arguments",
"Action + full arguments"});
this.eventlinelabelstyle.Location = new System.Drawing.Point(133, 19);
this.eventlinelabelstyle.Name = "eventlinelabelstyle";
this.eventlinelabelstyle.Size = new System.Drawing.Size(133, 21);
this.eventlinelabelstyle.TabIndex = 1;
this.useoppositesmartpivothandle.AutoSize = true;
this.useoppositesmartpivothandle.Location = new System.Drawing.Point(13, 333);
this.useoppositesmartpivothandle.Name = "useoppositesmartpivothandle";
this.useoppositesmartpivothandle.Size = new System.Drawing.Size(321, 17);
this.useoppositesmartpivothandle.TabIndex = 12;
this.useoppositesmartpivothandle.Text = "Opposite side/vertex is smart pivot handle on triangular sectors";
this.useoppositesmartpivothandle.UseVisualStyleBackColor = true;
//
// PreferencesForm
//
@ -721,6 +733,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.Text = "PreferencesForm";
this.tabs.ResumeLayout(false);
this.taboptions.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox3.ResumeLayout(false);
@ -729,7 +742,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.groupBox2.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -786,5 +798,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.ComboBox eventlinelabelvisibility;
private System.Windows.Forms.ComboBox eventlinelabelstyle;
private System.Windows.Forms.CheckBox useoppositesmartpivothandle;
}
}

View file

@ -67,6 +67,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
scaletexturesonslopes.SelectedIndex = General.Settings.ReadPluginSetting("scaletexturesonslopes", 0);
eventlinelabelvisibility.SelectedIndex = General.Settings.ReadPluginSetting("eventlinelabelvisibility", 3);
eventlinelabelstyle.SelectedIndex = General.Settings.ReadPluginSetting("eventlinelabelstyle", 2);
useoppositesmartpivothandle.Checked = General.Settings.ReadPluginSetting("useoppositesmartpivothandle", true);
}
#endregion
@ -97,6 +98,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Settings.WritePluginSetting("scaletexturesonslopes", scaletexturesonslopes.SelectedIndex);
General.Settings.WritePluginSetting("eventlinelabelvisibility", eventlinelabelvisibility.SelectedIndex);
General.Settings.WritePluginSetting("eventlinelabelstyle", eventlinelabelstyle.SelectedIndex);
General.Settings.WritePluginSetting("useoppositesmartpivothandle", useoppositesmartpivothandle.Checked);
General.Settings.SwitchViewModes = switchviewmodes.Checked; //mxd
General.Settings.SplitLineBehavior = (SplitLineBehavior)splitbehavior.SelectedIndex;//mxd

View file

@ -518,6 +518,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
Vector3D delta = General.Map.VisualCamera.Target - General.Map.VisualCamera.Position;
delta = delta.GetFixedLength(General.Settings.ViewDistance * PICK_RANGE);
VisualPickResult newtarget = PickObject(start, start + delta);
VisualSlope pickedhandle = null;
// Should we update the info on panels?
bool updateinfo = (newtarget.picked != target.picked);
@ -549,19 +550,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
usedslopehandles.Add((VisualSlope)newtarget.picked);
// Get the smart pivot handle for the targeted slope handle, so that it can be drawn
VisualSlope handle = ((VisualSlope)newtarget.picked).GetSmartPivotHandle();
if (handle != null)
{
handle.SmartPivot = true;
usedslopehandles.Add(handle);
}
pickedhandle = ((VisualSlope)newtarget.picked);
}
}
// Apply new target
target = newtarget;
// Get the smart pivot handle for the targeted slope handle, so that it can be drawn. We have to do it after the current
// target is set because otherwise it might get wrong results if the old target was a floor/ceiling
if (pickedhandle != null)
{
VisualSlope handle = pickedhandle.GetSmartPivotHandle();
if (handle != null)
{
handle.SmartPivot = true;
usedslopehandles.Add(handle);
}
}
// Show target info
if (updateinfo)
ShowTargetInfo();

View file

@ -163,9 +163,20 @@ namespace CodeImp.DoomBuilder.VisualModes
/// <returns></returns>
public override VisualSlope GetSmartPivotHandle()
{
List<IVisualEventReceiver> selectedsectors = mode.GetSelectedObjects(true, false, false, false, false);
// Special handling for triangular sectors
if (selectedsectors.Count == 0 && BuilderPlug.Me.UseOppositeSmartPivotHandle && sidedef.Sector.Sidedefs.Count == 3)
{
foreach(VisualVertexSlope vvs in mode.VertexSlopeHandles[sidedef.Sector])
{
if (vvs.Level == level && !vvs.Vertex.Linedefs.Contains(sidedef.Line))
return vvs;
}
}
VisualSlope handle = this;
List<VisualSidedefSlope> potentialhandles = new List<VisualSidedefSlope>();
List<IVisualEventReceiver> selectedsectors = mode.GetSelectedObjects(true, false, false, false, false);
if (selectedsectors.Count == 0)
{
@ -293,6 +304,15 @@ namespace CodeImp.DoomBuilder.VisualModes
return new Vector3D(sidedef.Line.Line.GetCoordinatesAt(0.5), level.plane.GetZ(sidedef.Line.Line.GetCoordinatesAt(0.5)));
}
public List<Vector3D> GetPivotPoints()
{
return new List<Vector3D>()
{
new Vector3D(sidedef.Line.Start.Position, level.plane.GetZ(sidedef.Line.Start.Position)),
new Vector3D(sidedef.Line.End.Position, level.plane.GetZ(sidedef.Line.End.Position))
};
}
#endregion
#region ================== Events
@ -339,7 +359,7 @@ namespace CodeImp.DoomBuilder.VisualModes
mode.CreateUndo("Change slope");
Plane originalplane = level.plane;
Plane pivotplane = pivothandle is VisualVertexSlope ? ((VisualVertexSlope)pivothandle).Level.plane : ((VisualSidedefSlope)pivothandle).Level.plane;
Plane pivotplane = ((BaseVisualSlope)pivothandle).Level.plane;
// Build a new plane. p1 and p2 are the points of the slope handle that is modified, with the changed amound added; p3 is on the line of the pivot handle
Vector3D p1 = new Vector3D(sidedef.Line.Start.Position, originalplane.GetZ(sidedef.Line.Start.Position) + amount);

View file

@ -171,9 +171,20 @@ namespace CodeImp.DoomBuilder.VisualModes
/// <returns></returns>
public override VisualSlope GetSmartPivotHandle()
{
List<IVisualEventReceiver> selectedsectors = mode.GetSelectedObjects(true, false, false, false, false);
// Special handling for triangular sectors
if (selectedsectors.Count == 0 && BuilderPlug.Me.UseOppositeSmartPivotHandle && sector.Sidedefs.Count == 3)
{
foreach (VisualSidedefSlope vss in mode.SidedefSlopeHandles[sector])
{
if (vss.Level == level && !(vss.Sidedef.Line.Start == vertex || vss.Sidedef.Line.End == vertex))
return vss;
}
}
VisualSlope handle = this;
List<VisualVertexSlope> potentialhandles = new List<VisualVertexSlope>();
List<IVisualEventReceiver> selectedsectors = mode.GetSelectedObjects(true, false, false, false, false);
if (selectedsectors.Count == 0)
{
@ -315,14 +326,26 @@ namespace CodeImp.DoomBuilder.VisualModes
Plane originalplane = level.plane;
// Build a new plane. Since we only got 2 points (the pivot point of the pivot handle and the vertex slope vertex) we need
// to create a third point. That's done by getting the perpendicular of the line between the aforementioned 2 points, then
// add the perpendicular to the vertex position of the vertex slope vertex
Vector3D p3 = pivothandle.GetPivotPoint();
Vector2D perp = new Line2D(vertex.Position, p3).GetPerpendicular();
Vector3D p1, p2, p3;
Vector3D p1 = new Vector3D(vertex.Position, originalplane.GetZ(vertex.Position) + amount);
Vector3D p2 = new Vector3D(vertex.Position + perp, originalplane.GetZ(vertex.Position + perp) + amount);
if (pivothandle is VisualVertexSlope)
{
// Build a new plane. Since we only got 2 points (the pivot point of the pivot handle and the vertex slope vertex) we need
// to create a third point. That's done by getting the perpendicular of the line between the aforementioned 2 points, then
// add the perpendicular to the vertex position of the vertex slope vertex
p3 = pivothandle.GetPivotPoint();
Vector2D perp = new Line2D(vertex.Position, p3).GetPerpendicular();
p1 = new Vector3D(vertex.Position, originalplane.GetZ(vertex.Position) + amount);
p2 = new Vector3D(vertex.Position + perp, originalplane.GetZ(vertex.Position + perp) + amount);
}
else // VisualSidedefSlope
{
List<Vector3D> pivotpoints = ((VisualSidedefSlope)pivothandle).GetPivotPoints();
p1 = new Vector3D(vertex.Position, originalplane.GetZ(vertex.Position) + amount);
p2 = pivotpoints[0];
p3 = pivotpoints[1];
}
Plane plane = new Plane(p1, p2, p3, true);