Changed, Visual mode: texture alpha is now tested when highlighting doublesided linedefs.

Changed, Linedef Edit window, Visual mode, UDMF: when "Edit windows remember selected tabs" setting is enabled and Front or Back tab was previously selected, the tab, which corresponds to the highlighted side will be selected.
This commit is contained in:
MaxED 2015-06-15 09:50:22 +00:00
parent 35fd6e1dcc
commit c500edaf8d
5 changed files with 57 additions and 5 deletions

View file

@ -53,6 +53,7 @@ namespace CodeImp.DoomBuilder.Windows
DialogResult ShowEditVertices(ICollection<Vertex> vertices);
DialogResult ShowEditVertices(ICollection<Vertex> vertices, bool allowPositionChange); //mxd
DialogResult ShowEditLinedefs(ICollection<Linedef> lines);
DialogResult ShowEditLinedefs(ICollection<Linedef> lines, bool selectfront, bool selectback); //mxd
DialogResult ShowEditSectors(ICollection<Sector> sectors);
DialogResult ShowEditThings(ICollection<Thing> things);
void ShowLinedefInfo(Linedef l);

View file

@ -155,7 +155,7 @@ namespace CodeImp.DoomBuilder.Windows
#region ================== Constructor
public LinedefEditFormUDMF()
public LinedefEditFormUDMF(bool selectfront, bool selectback)
{
// Initialize
InitializeComponent();
@ -165,7 +165,14 @@ namespace CodeImp.DoomBuilder.Windows
{
this.StartPosition = FormStartPosition.Manual;
this.Location = location;
if(General.Settings.StoreSelectedEditTab && activetab > 0) tabs.SelectTab(activetab);
if(General.Settings.StoreSelectedEditTab && activetab > 0)
{
// When front or back tab was previously selected, switch to appropriate side (selectfront/selectback are set in BaseVisualGeometrySidedef.OnEditEnd)
if((selectfront || selectback) && (activetab == 1 || activetab == 2))
tabs.SelectTab(selectfront ? 1 : 2);
else
tabs.SelectTab(activetab);
}
}
// Fill flags lists

View file

@ -3523,13 +3523,19 @@ namespace CodeImp.DoomBuilder.Windows
// This shows the dialog to edit lines
public DialogResult ShowEditLinedefs(ICollection<Linedef> lines)
{
return ShowEditLinedefs(lines, false, false);
}
// This shows the dialog to edit lines
public DialogResult ShowEditLinedefs(ICollection<Linedef> lines, bool selectfront, bool selectback)
{
DialogResult result;
// Show line edit dialog
if(General.Map.UDMF) //mxd
{
LinedefEditFormUDMF f = new LinedefEditFormUDMF();
LinedefEditFormUDMF f = new LinedefEditFormUDMF(selectfront, selectback);
DisableProcessing(); //mxd
f.Setup(lines);
EnableProcessing(); //mxd

View file

@ -1291,7 +1291,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged;
mode.StartRealtimeInterfaceUpdate(SelectionType.Linedefs);
DialogResult result = General.Interface.ShowEditLinedefs(linedefs);
DialogResult result = General.Interface.ShowEditLinedefs(linedefs, Sidedef.IsFront, !Sidedef.IsFront);
mode.StopRealtimeInterfaceUpdate(SelectionType.Linedefs);
General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged;

View file

@ -295,7 +295,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
if(!repeatmidtex)
{
// Whe nthe texture is not repeated, leave when outside crop planes
// When the texture is not repeated, leave when outside crop planes
if((pickintersect.z < bottomclipplane.GetZ(pickintersect)) ||
(pickintersect.z > topclipplane.GetZ(pickintersect)))
return false;
@ -303,6 +303,44 @@ namespace CodeImp.DoomBuilder.BuilderModes
return base.PickFastReject(from, to, dir);
}
//mxd. Alpha based picking
public override bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
{
if(!Texture.IsImageLoaded) return base.PickAccurate(from, to, dir, ref u_ray);
float u;
new Line2D(from, to).GetIntersection(Sidedef.Line.Line, out u);
if(Sidedef != Sidedef.Line.Front) u = 1.0f - u;
// Get correct vertical offset to texture space...
float zoffset;
if(repeatmidtex)
{
if(Sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
zoffset = Sidedef.Sector.FloorHeight;
else
zoffset = Sidedef.Sector.CeilHeight;
}
else
{
zoffset = bottomclipplane.GetZ(pickintersect);
}
// Get offsets in texture space
int ox = (int)Math.Floor((u * Sidedef.Line.Length * UDMFTools.GetFloat(Sidedef.Fields, "scalex_mid", 1.0f) + Sidedef.OffsetX + UDMFTools.GetFloat(Sidedef.Fields, "offsetx_mid")) % Texture.Width);
int oy = (int)Math.Floor(((pickintersect.z - zoffset) * UDMFTools.GetFloat(Sidedef.Fields, "scaley_mid", 1.0f) - Sidedef.OffsetY - UDMFTools.GetFloat(Sidedef.Fields, "offsety_mid")) % Texture.Height);
if(ox < 0) ox = Texture.Width + ox;
if(oy < 0) oy = Texture.Height + oy;
// Check pixel alpha
if(Texture.GetBitmap().GetPixel(General.Clamp(ox, 0, Texture.Width - 1), General.Clamp(Texture.Height - oy, 0, Texture.Height - 1)).A > 0)
{
return base.PickAccurate(from, to, dir, ref u_ray);
}
return false;
}
// Return texture name
public override string GetTextureName()