Fixed, Visual mode: fixed inability to drag auto-selected sidedef parts using mouse when "Synchronize selection between Visual and Classic modes" setting was enabled.

Fixed, Visual mode: fixed incorrect auto-selected sidedefs texture offset clamping when "Synchronize selection between Visual and Classic modes" setting was enabled.
This commit is contained in:
MaxED 2016-01-16 12:46:44 +00:00
parent fd008a9617
commit 0258cf10e2
6 changed files with 84 additions and 59 deletions

View file

@ -155,6 +155,7 @@ namespace CodeImp.DoomBuilder.VisualModes
triangles = vertices.Length / 3;
CalculateNormals(); //mxd
PerformAutoSelection(); //mxd
}
else
{
@ -266,6 +267,9 @@ namespace CodeImp.DoomBuilder.VisualModes
return false;
}
//mxd
protected abstract void PerformAutoSelection();
#endregion
}

View file

@ -67,7 +67,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
private int prevoffsety; // want to calculate with delta offsets to prevent
// inaccuracy in the dragging.
private static List<BaseVisualSector> updateList; //mxd
private static List<BaseVisualSector> updatelist; //mxd
protected bool performautoselection; //mxd
#endregion
@ -98,6 +99,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
protected abstract void UpdateSkyRenderFlag(); //mxd
public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
//mxd
override protected void PerformAutoSelection()
{
if(!performautoselection) return;
if(Triangles > 0)
{
this.selected = true;
mode.AddSelectedObject(this);
}
performautoselection = false;
}
// This swaps triangles so that the plane faces the other way
protected static void SwapTriangleVertices(WorldVertex[] verts)
{
@ -774,12 +788,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
//mxd
List<Sector> sectors = mode.GetSelectedSectors();
updateList = new List<BaseVisualSector>();
updatelist = new List<BaseVisualSector>();
foreach(Sector s in sectors)
{
if(mode.VisualSectorExists(s))
updateList.Add((BaseVisualSector)mode.GetVisualSector(s));
updatelist.Add((BaseVisualSector)mode.GetVisualSector(s));
}
General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged; //mxd
@ -788,8 +802,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.StopRealtimeInterfaceUpdate(SelectionType.Sectors); //mxd
General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged; //mxd
updateList.Clear(); //mxd
updateList = null; //mxd
updatelist.Clear(); //mxd
updatelist = null; //mxd
if(result == DialogResult.OK) mode.RebuildElementData(); //mxd
}
@ -798,7 +812,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd
private void Interface_OnEditFormValuesChanged(object sender, EventArgs e)
{
foreach(BaseVisualSector vs in updateList) vs.UpdateSectorGeometry(true);
foreach(BaseVisualSector vs in updatelist) vs.UpdateSectorGeometry(true);
}
// Sector height change

View file

@ -61,7 +61,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
private int prevoffsetx; // We have to provide delta offsets, but I don't
private int prevoffsety; // want to calculate with delta offsets to prevent
// inaccuracy in the dragging.
private static List<BaseVisualSector> updateList; //mxd
private static List<BaseVisualSector> updatelist; //mxd
private bool performautoselection; //mxd
// Undo/redo
private int undoticket;
@ -84,19 +85,36 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.deltaz = new Vector3D(0.0f, 0.0f, 1.0f);
this.deltaxy = (sd.Line.End.Position - sd.Line.Start.Position) * sd.Line.LengthInv;
if(!sd.IsFront) this.deltaxy = -this.deltaxy;
//mxd
if(mode.UseSelectionFromClassicMode && sd.Line.Selected)
{
this.selected = true;
mode.AddSelectedObject(this);
}
this.performautoselection = (mode.UseSelectionFromClassicMode && sd.Line.Selected); //mxd
}
#endregion
#region ================== Methods
//mxd
override protected void PerformAutoSelection()
{
if(!performautoselection) return;
if(Triangles > 0)
{
dragstartanglexy = General.Map.VisualCamera.AngleXY;
dragstartanglez = General.Map.VisualCamera.AngleZ;
dragorigin = pickintersect;
Point texoffset = GetTextureOffset();
startoffsetx = texoffset.X;
startoffsety = texoffset.Y;
prevoffsetx = texoffset.X;
prevoffsety = texoffset.Y;
this.selected = true;
mode.AddSelectedObject(this);
}
performautoselection = false;
}
// This sets the renderstyle from linedef information and returns the alpha value or the vertices
protected byte SetLinedefRenderstyle(bool solidasmask)
{
@ -1164,10 +1182,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
dragstartanglexy = General.Map.VisualCamera.AngleXY;
dragstartanglez = General.Map.VisualCamera.AngleZ;
dragorigin = pickintersect;
startoffsetx = GetTextureOffset().X;
startoffsety = GetTextureOffset().Y;
prevoffsetx = GetTextureOffset().X;
prevoffsety = GetTextureOffset().Y;
Point texoffset = GetTextureOffset(); //mxd
startoffsetx = texoffset.X;
startoffsety = texoffset.Y;
prevoffsetx = texoffset.X;
prevoffsety = texoffset.Y;
}
// Select button released
@ -1203,13 +1223,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(General.Interface.IsActiveWindow)
{
List<Linedef> linedefs = mode.GetSelectedLinedefs();
updateList = new List<BaseVisualSector>(); //mxd
updatelist = new List<BaseVisualSector>(); //mxd
foreach(Linedef l in linedefs)
{
if(l.Front != null && mode.VisualSectorExists(l.Front.Sector))
updateList.Add((BaseVisualSector)mode.GetVisualSector(l.Front.Sector));
updatelist.Add((BaseVisualSector)mode.GetVisualSector(l.Front.Sector));
if(l.Back != null && mode.VisualSectorExists(l.Back.Sector))
updateList.Add((BaseVisualSector)mode.GetVisualSector(l.Back.Sector));
updatelist.Add((BaseVisualSector)mode.GetVisualSector(l.Back.Sector));
}
General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged;
@ -1218,8 +1238,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.StopRealtimeInterfaceUpdate(SelectionType.Linedefs);
General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged;
updateList.Clear();
updateList = null;
updatelist.Clear();
updatelist = null;
//mxd. Effects may need updating...
if(result == DialogResult.OK) mode.RebuildElementData();
@ -1229,7 +1249,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd
private void Interface_OnEditFormValuesChanged(object sender, EventArgs e)
{
foreach(BaseVisualSector vs in updateList) vs.UpdateSectorGeometry(false);
foreach(BaseVisualSector vs in updatelist) vs.UpdateSectorGeometry(false);
}
// Mouse moves

View file

@ -1610,20 +1610,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
List<IVisualEventReceiver> objs = new List<IVisualEventReceiver>();
foreach(IVisualEventReceiver i in selectedobjects)
{
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i);
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i);
else if((i is BaseVisualThing) && includethings) objs.Add(i);
else if((i is BaseVisualVertex) && includevertices) objs.Add(i);//mxd
if(includesectors && (i is BaseVisualGeometrySector) /*&& ((BaseVisualGeometrySector)i).Triangles > 0*/) objs.Add(i);
else if(includesidedefs && (i is BaseVisualGeometrySidedef) /*&& ((BaseVisualGeometrySidedef)i).Triangles > 0*/) objs.Add(i);
else if(includethings && (i is BaseVisualThing)) objs.Add(i);
else if(includevertices && (i is BaseVisualVertex)) objs.Add(i); //mxd
}
// Add highlight?
if(selectedobjects.Count == 0)
{
IVisualEventReceiver i = (target.picked as IVisualEventReceiver);
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i);
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i);
else if((i is BaseVisualThing) && includethings) objs.Add(i);
else if((i is BaseVisualVertex) && includevertices) objs.Add(i);//mxd
if(includesectors && (i is BaseVisualGeometrySector) /*&& ((BaseVisualGeometrySector)i).Triangles > 0*/) objs.Add(i);
else if(includesidedefs && (i is BaseVisualGeometrySidedef) /*&& ((BaseVisualGeometrySidedef)i).Triangles > 0*/) objs.Add(i);
else if(includethings && (i is BaseVisualThing)) objs.Add(i);
else if(includevertices && (i is BaseVisualVertex)) objs.Add(i); //mxd
}
return objs;

View file

@ -40,7 +40,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
public bool innerSide; //mxd
private bool innerside; //mxd
#endregion
@ -56,13 +56,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd
geometrytype = VisualGeometryType.CEILING;
partname = "ceiling";
//mxd
if(mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected && (General.Map.ViewMode == ViewMode.CeilingTextures || General.Map.ViewMode == ViewMode.Normal))
{
this.selected = true;
mode.AddSelectedObject(this);
}
performautoselection = mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected && (General.Map.ViewMode == ViewMode.CeilingTextures || General.Map.ViewMode == ViewMode.Normal);
// We have no destructor
GC.SuppressFinalize(this);
@ -71,15 +65,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This builds the geometry. Returns false when no geometry created.
public override bool Setup(SectorLevel level, Effect3DFloor extrafloor)
{
return Setup(level, extrafloor, innerSide);
return Setup(level, extrafloor, innerside);
}
//mxd
public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerSide)
public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerside)
{
Sector s = level.sector;
Vector2D texscale;
this.innerSide = innerSide; //mxd
this.innerside = innerside; //mxd
base.Setup(level, extrafloor);
@ -169,7 +163,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// The sector triangulation created clockwise triangles that
// are right up for the floor. For the ceiling we must flip
// the triangles upside down.
if(extrafloor == null || extrafloor.VavoomType || innerSide)
if(extrafloor == null || extrafloor.VavoomType || innerside)
SwapTriangleVertices(verts);
// Determine render pass
@ -457,7 +451,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
// Check if our ray starts at the correct side of the plane
if((innerSide && level.plane.Distance(from) < 0.0f) || (!innerSide && level.plane.Distance(from) > 0.0f)) //mxd
if((innerside && level.plane.Distance(from) < 0.0f) || (!innerside && level.plane.Distance(from) > 0.0f)) //mxd
//if(level.plane.Distance(from) > 0.0f)
{
// Calculate the intersection

View file

@ -40,7 +40,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
private bool innerSide; //mxd
private bool innerside; //mxd
#endregion
@ -56,14 +56,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd
geometrytype = VisualGeometryType.FLOOR;
partname = "floor";
//mxd
if(mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected
&& (General.Map.ViewMode == ViewMode.FloorTextures || General.Map.ViewMode == ViewMode.Normal))
{
this.selected = true;
mode.AddSelectedObject(this);
}
performautoselection = mode.UseSelectionFromClassicMode && vs != null && vs.Sector.Selected && (General.Map.ViewMode == ViewMode.FloorTextures || General.Map.ViewMode == ViewMode.Normal);
// We have no destructor
GC.SuppressFinalize(this);
@ -72,15 +65,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This builds the geometry. Returns false when no geometry created.
public override bool Setup(SectorLevel level, Effect3DFloor extrafloor)
{
return Setup(level, extrafloor, innerSide);
return Setup(level, extrafloor, innerside);
}
//mxd
public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerSide)
public bool Setup(SectorLevel level, Effect3DFloor extrafloor, bool innerside)
{
Sector s = level.sector;
Vector2D texscale;
this.innerSide = innerSide;
this.innerside = innerside;
base.Setup(level, extrafloor);
@ -171,7 +164,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// The sector triangulation created clockwise triangles that
// are right up for the floor. For the ceiling we must flip
// the triangles upside down.
if((extrafloor != null) && !extrafloor.VavoomType && !innerSide)
if((extrafloor != null) && !extrafloor.VavoomType && !innerside)
SwapTriangleVertices(verts);
// Determine render pass
@ -411,7 +404,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
// Check if our ray starts at the correct side of the plane
if((!innerSide && level.plane.Distance(from) > 0.0f) || (innerSide && level.plane.Distance(from) < 0.0f))
if((!innerside && level.plane.Distance(from) > 0.0f) || (innerside && level.plane.Distance(from) < 0.0f))
{
// Calculate the intersection
if(level.plane.GetIntersection(from, to, ref pickrayu))