the "Marked" property of map elements now indicates the set we are working with, not the user selection

This commit is contained in:
codeimp 2008-05-01 14:10:38 +00:00
parent 018f8ab26a
commit e95a24f281
12 changed files with 270 additions and 157 deletions

View file

@ -58,16 +58,16 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
private List<Vector2D> oldpositions; private List<Vector2D> oldpositions;
// List of selected items // List of selected items
private ICollection<Vertex> selectedverts; protected ICollection<Vertex> selectedverts;
// List of non-selected items // List of non-selected items
private ICollection<Vertex> unselectedverts; protected ICollection<Vertex> unselectedverts;
// List of unstable lines // List of unstable lines
protected ICollection<Linedef> unstablelines; protected ICollection<Linedef> unstablelines;
// List of unselected lines // List of unselected lines
protected ICollection<Linedef> unselectedlines; protected ICollection<Linedef> snaptolines;
// Keep track of view changes // Keep track of view changes
private float lastoffsetx; private float lastoffsetx;
@ -107,21 +107,26 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
#region ================== Methods #region ================== Methods
// Constructor to start dragging immediately // Constructor to start dragging immediately
protected void StartDrag(EditMode basemode, Vertex dragitem, Vector2D dragstartmappos, ICollection<Vertex> selected, ICollection<Vertex> unselected) protected void StartDrag(EditMode basemode, Vector2D dragstartmappos)
{ {
// Initialize // Initialize
this.dragitem = dragitem;
this.dragstartmappos = dragstartmappos; this.dragstartmappos = dragstartmappos;
this.basemode = basemode; this.basemode = basemode;
Cursor.Current = Cursors.AppStarting; Cursor.Current = Cursors.AppStarting;
// Make list of selected vertices // Make list of selected vertices
selectedverts = selected; selectedverts = General.Map.Map.GetMarkedVertices(true);
// Make list of non-selected vertices // Make list of non-selected vertices
// This will be used for snapping to nearest items // This will be used for snapping to nearest items
unselectedverts = unselected; unselectedverts = General.Map.Map.GetMarkedVertices(false);
// Get the nearest vertex for snapping
dragitem = MapSet.NearestVertex(selectedverts, dragstartmappos);
// Lines to snap to
snaptolines = General.Map.Map.LinedefsFromMarkedVertices(true, false, false);
// Make old positions list // Make old positions list
// We will use this as reference to move the vertices, or to move them back on cancel // We will use this as reference to move the vertices, or to move them back on cancel
@ -148,13 +153,14 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
private bool MoveGeometryRelative(Vector2D offset, bool snapgrid, bool snapnearest) private bool MoveGeometryRelative(Vector2D offset, bool snapgrid, bool snapnearest)
{ {
Vector2D oldpos = dragitem.Position; Vector2D oldpos = dragitem.Position;
Vector2D anchorpos = dragitemposition + offset;
int i = 0; int i = 0;
// Snap to nearest? // Snap to nearest?
if(snapnearest) if(snapnearest)
{ {
// Find nearest unselected vertex within range // Find nearest unselected vertex within range
Vertex nv = MapSet.NearestVertexSquareRange(unselectedverts, mousemappos, VerticesMode.VERTEX_HIGHLIGHT_RANGE / renderer.Scale); Vertex nv = MapSet.NearestVertexSquareRange(unselectedverts, anchorpos, VerticesMode.VERTEX_HIGHLIGHT_RANGE / renderer.Scale);
if(nv != null) if(nv != null)
{ {
// Move the dragged item // Move the dragged item
@ -169,7 +175,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
else else
{ {
// Find the nearest unselected line within range // Find the nearest unselected line within range
Linedef nl = MapSet.NearestLinedefRange(unselectedlines, mousemappos, LinedefsMode.LINEDEF_HIGHLIGHT_RANGE / renderer.Scale); Linedef nl = MapSet.NearestLinedefRange(snaptolines, anchorpos, LinedefsMode.LINEDEF_HIGHLIGHT_RANGE / renderer.Scale);
if(nl != null) if(nl != null)
{ {
// Snap to grid? // Snap to grid?
@ -183,7 +189,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
Vector2D found_coord = new Vector2D(); Vector2D found_coord = new Vector2D();
foreach(Vector2D v in coords) foreach(Vector2D v in coords)
{ {
Vector2D delta = mousemappos - v; Vector2D delta = anchorpos - v;
if(delta.GetLengthSq() < found_distance) if(delta.GetLengthSq() < found_distance)
{ {
found_distance = delta.GetLengthSq(); found_distance = delta.GetLengthSq();
@ -203,10 +209,10 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
else else
{ {
// Move the dragged item // Move the dragged item
dragitem.Move(nl.NearestOnLine(mousemappos)); dragitem.Move(nl.NearestOnLine(anchorpos));
// Align to line here // Align to line here
offset = nl.NearestOnLine(mousemappos) - dragitemposition; offset = nl.NearestOnLine(anchorpos) - dragitemposition;
} }
} }
} }
@ -216,13 +222,13 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
if(snapgrid) if(snapgrid)
{ {
// Move the dragged item // Move the dragged item
dragitem.Move(dragitemposition + offset); dragitem.Move(anchorpos);
// Snap item to grid // Snap item to grid
dragitem.SnapToGrid(); dragitem.SnapToGrid();
// Adjust the offset // Adjust the offset
offset += dragitem.Position - (dragitemposition + offset); offset += dragitem.Position - anchorpos;
} }
// Drag item moved? // Drag item moved?
@ -293,7 +299,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest); MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest);
// Stitch geometry // Stitch geometry
General.Map.Map.StitchGeometry(selectedverts, unselectedverts); if(snaptonearest) General.Map.Map.StitchGeometry();
// Update cached values // Update cached values
General.Map.Map.Update(); General.Map.Map.Update();

View file

@ -63,17 +63,17 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Constructor to start dragging immediately // Constructor to start dragging immediately
public DragLinedefsMode(EditMode basemode, Vector2D dragstartmappos) public DragLinedefsMode(EditMode basemode, Vector2D dragstartmappos)
{ {
// Get the nearest vertex for snapping // Mark what we are dragging
Vertex nearest = MapSet.NearestVertex(General.Map.Map.GetVerticesFromLinesSelection(true), dragstartmappos); General.Map.Map.ClearAllMarks();
General.Map.Map.MarkSelectedLinedefs(true, true);
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
foreach(Vertex v in verts) v.Marked = true;
// Get selected lines // Get selected lines
selectedlines = General.Map.Map.GetLinedefsSelection(true); selectedlines = General.Map.Map.GetLinedefsSelection(true);
unselectedlines = General.Map.Map.GetLinedefsSelection(false);
// Initialize // Initialize
base.StartDrag(basemode, nearest, dragstartmappos, base.StartDrag(basemode, dragstartmappos);
General.Map.Map.GetVerticesFromLinesSelection(true),
General.Map.Map.GetVerticesFromLinesSelectionEx(false));
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -107,7 +107,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
{ {
// Select vertices from lines selection // Select vertices from lines selection
General.Map.Map.ClearSelectedVertices(); General.Map.Map.ClearSelectedVertices();
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesSelection(true); ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
foreach(Vertex v in verts) v.Selected = true; foreach(Vertex v in verts) v.Selected = true;
// Perform normal disengage // Perform normal disengage
@ -133,7 +133,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
if(renderer.StartPlotter(true)) if(renderer.StartPlotter(true))
{ {
// Render lines and vertices // Render lines and vertices
renderer.PlotLinedefSet(unselectedlines); renderer.PlotLinedefSet(snaptolines);
renderer.PlotLinedefSet(unstablelines);
renderer.PlotLinedefSet(selectedlines); renderer.PlotLinedefSet(selectedlines);
renderer.PlotVerticesSet(General.Map.Map.Vertices); renderer.PlotVerticesSet(General.Map.Map.Vertices);

View file

@ -64,18 +64,18 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Constructor to start dragging immediately // Constructor to start dragging immediately
public DragSectorsMode(EditMode basemode, Vector2D dragstartmappos) public DragSectorsMode(EditMode basemode, Vector2D dragstartmappos)
{ {
// Get the nearest vertex for snapping // Mark what we are dragging
Vertex nearest = MapSet.NearestVertex(General.Map.Map.GetVerticesFromLinesSelection(true), dragstartmappos); General.Map.Map.ClearAllMarks();
General.Map.Map.MarkSelectedLinedefs(true, true);
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
foreach(Vertex v in verts) v.Marked = true;
// Get selected lines // Get selected lines
selectedlines = General.Map.Map.GetLinedefsSelection(true); selectedlines = General.Map.Map.GetLinedefsSelection(true);
unselectedlines = General.Map.Map.GetLinedefsSelection(false);
selectedsectors = General.Map.Map.GetSectorsSelection(true); selectedsectors = General.Map.Map.GetSectorsSelection(true);
// Initialize // Initialize
base.StartDrag(basemode, nearest, dragstartmappos, base.StartDrag(basemode, dragstartmappos);
General.Map.Map.GetVerticesFromLinesSelection(true),
General.Map.Map.GetVerticesFromLinesSelectionEx(false));
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -109,7 +109,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
{ {
// Select vertices from lines selection // Select vertices from lines selection
General.Map.Map.ClearSelectedVertices(); General.Map.Map.ClearSelectedVertices();
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesSelection(true); ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
foreach(Vertex v in verts) v.Selected = true; foreach(Vertex v in verts) v.Selected = true;
// Perform normal disengage // Perform normal disengage
@ -139,7 +139,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
if(renderer.StartPlotter(true)) if(renderer.StartPlotter(true))
{ {
// Render lines and vertices // Render lines and vertices
renderer.PlotLinedefSet(unselectedlines); renderer.PlotLinedefSet(snaptolines);
renderer.PlotLinedefSet(unstablelines);
renderer.PlotLinedefSet(selectedlines); renderer.PlotLinedefSet(selectedlines);
renderer.PlotVerticesSet(General.Map.Map.Vertices); renderer.PlotVerticesSet(General.Map.Map.Vertices);

View file

@ -98,12 +98,16 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
Cursor.Current = Cursors.AppStarting; Cursor.Current = Cursors.AppStarting;
// Get the nearest thing for snapping // Mark what we are dragging
dragitem = MapSet.NearestThing(General.Map.Map.GetThingsSelection(true), dragstartmappos); General.Map.Map.ClearAllMarks();
General.Map.Map.MarkSelectedThings(true, true);
// Get selected things // Get selected things
selectedthings = General.Map.Map.GetThingsSelection(true); selectedthings = General.Map.Map.GetMarkedThings(true);
unselectedthings = General.Map.Map.GetThingsSelection(false); unselectedthings = General.Map.Map.GetMarkedThings(false);
// Get the nearest thing for snapping
dragitem = MapSet.NearestThing(selectedthings, dragstartmappos);
// Make old positions list // Make old positions list
// We will use this as reference to move the vertices, or to move them back on cancel // We will use this as reference to move the vertices, or to move them back on cancel
@ -284,7 +288,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest); MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest);
// Update cached values // Update cached values
General.Map.Map.Update(); General.Map.Map.Update(false, false);
// Map is changed // Map is changed
General.Map.IsChanged = true; General.Map.IsChanged = true;

View file

@ -50,9 +50,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
#region ================== Variables #region ================== Variables
private ICollection<Vertex> selectedverts;
private ICollection<Vertex> unselectedverts;
#endregion #endregion
#region ================== Properties #region ================== Properties
@ -64,15 +61,12 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
// Constructor to start dragging immediately // Constructor to start dragging immediately
public DragVerticesMode(EditMode basemode, Vertex dragitem, Vector2D dragstartmappos) public DragVerticesMode(EditMode basemode, Vertex dragitem, Vector2D dragstartmappos)
{ {
// Get selected vertices // Mark what we are dragging
selectedverts = General.Map.Map.GetVerticesSelection(true); General.Map.Map.ClearAllMarks();
unselectedverts = General.Map.Map.GetVerticesSelection(false); General.Map.Map.MarkSelectedVertices(true, true);
unselectedlines = General.Map.Map.LinedefsFromSelectedVertices(true, false, false);
// Initialize // Initialize
base.StartDrag(basemode, dragitem, dragstartmappos, base.StartDrag(basemode, dragstartmappos);
General.Map.Map.GetVerticesSelection(true),
General.Map.Map.GetVerticesSelection(false));
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);

View file

@ -161,8 +161,8 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
} }
// STEP 2: Merge the new geometry // STEP 2: Merge the new geometry
foreach(Vertex v in mergeverts) v.Selected = true; foreach(Vertex v in mergeverts) v.Marked = true;
map.StitchGeometry(mergeverts, nonmergeverts); map.StitchGeometry();
// STEP 3: Make sectors where possible // STEP 3: Make sectors where possible

View file

@ -77,6 +77,7 @@ namespace CodeImp.DoomBuilder.Map
// Selections // Selections
private bool selected; private bool selected;
private bool marked;
// Disposing // Disposing
private bool isdisposed = false; private bool isdisposed = false;
@ -95,6 +96,7 @@ namespace CodeImp.DoomBuilder.Map
public int Action { get { return action; } set { action = value; } } public int Action { get { return action; } set { action = value; } }
public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } } public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
public bool Selected { get { return selected; } set { selected = value; } } public bool Selected { get { return selected; } set { selected = value; } }
public bool Marked { get { return marked; } set { marked = value; } }
public float LengthSq { get { return lengthsq; } } public float LengthSq { get { return lengthsq; } }
public float Length { get { return length; } } public float Length { get { return length; } }
public float LengthInv { get { return lengthinv; } } public float LengthInv { get { return lengthinv; } }
@ -483,6 +485,7 @@ namespace CodeImp.DoomBuilder.Map
CopyPropertiesTo(nl); CopyPropertiesTo(nl);
SetEndVertex(v); SetEndVertex(v);
nl.selected = this.selected; nl.selected = this.selected;
nl.marked = this.marked;
// Copy front sidedef if exists // Copy front sidedef if exists
if(front != null) if(front != null)
@ -628,6 +631,7 @@ namespace CodeImp.DoomBuilder.Map
// If either of the two lines was selected, keep the other selected // If either of the two lines was selected, keep the other selected
if(this.selected) other.selected = true; if(this.selected) other.selected = true;
if(this.marked) other.marked = true;
// Apply single/double sided flags // Apply single/double sided flags
other.ApplySidedFlags(); other.ApplySidedFlags();

View file

@ -411,73 +411,6 @@ namespace CodeImp.DoomBuilder.Map
foreach(Sector s in sectors) s.Selected = false; foreach(Sector s in sectors) s.Selected = false;
} }
// Returns a collection of vertices that match a selected state
public ICollection<Vertex> GetVerticesSelection(bool selected)
{
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
foreach(Vertex v in vertices) if(v.Selected == selected) list.Add(v);
return list;
}
// Returns a collection of vertices that match a selected state on the linedefs
public ICollection<Vertex> GetVerticesFromLinesSelection(bool selected)
{
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
foreach(Vertex v in vertices)
{
foreach(Linedef l in v.Linedefs)
{
if(l.Selected == selected)
{
list.Add(v);
break;
}
}
}
return list;
}
// Returns a collection of vertices that match a selected state on the linedefs
// The difference with GetVerticesFromLinesSelection is that in this method
// ALL linedefs of a vertex must match the specified selected state.
public ICollection<Vertex> GetVerticesFromLinesSelectionEx(bool selected)
{
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
foreach(Vertex v in vertices)
{
bool qualified = true;
foreach(Linedef l in v.Linedefs)
{
if(l.Selected != selected)
{
qualified = false;
break;
}
}
if(qualified) list.Add(v);
}
return list;
}
// Returns a collection of vertices that match a selected state on the linedefs
public ICollection<Vertex> GetVerticesFromSectorsSelection(bool selected)
{
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
foreach(Vertex v in vertices)
{
foreach(Linedef l in v.Linedefs)
{
if( ((l.Front != null) && (l.Front.Sector.Selected == selected)) ||
((l.Back != null) && (l.Back.Sector.Selected == selected)) )
{
list.Add(v);
break;
}
}
}
return list;
}
// Returns a collection of things that match a selected state // Returns a collection of things that match a selected state
public ICollection<Thing> GetThingsSelection(bool selected) public ICollection<Thing> GetThingsSelection(bool selected)
{ {
@ -504,6 +437,164 @@ namespace CodeImp.DoomBuilder.Map
#endregion #endregion
#region ================== Marking
// This clears all marks
public void ClearAllMarks()
{
ClearMarkedVertices(false);
ClearMarkedThings(false);
ClearMarkedLinedefs(false);
ClearMarkedSectors(false);
}
// This clears marked vertices
public void ClearMarkedVertices(bool mark)
{
foreach(Vertex v in vertices) v.Marked = mark;
}
// This clears marked things
public void ClearMarkedThings(bool mark)
{
foreach(Thing t in things) t.Marked = mark;
}
// This clears marked linedefs
public void ClearMarkedLinedefs(bool mark)
{
foreach(Linedef l in linedefs) l.Marked = mark;
}
// This clears marked sectors
public void ClearMarkedSectors(bool mark)
{
foreach(Sector s in sectors) s.Marked = mark;
}
// Returns a collection of vertices that match a marked state
public ICollection<Vertex> GetMarkedVertices(bool mark)
{
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
foreach(Vertex v in vertices) if(v.Marked == mark) list.Add(v);
return list;
}
// Returns a collection of things that match a marked state
public ICollection<Thing> GetMarkedThings(bool mark)
{
List<Thing> list = new List<Thing>(things.Count >> 1);
foreach(Thing t in things) if(t.Marked == mark) list.Add(t);
return list;
}
// Returns a collection of linedefs that match a marked state
public ICollection<Linedef> GetMarkedLinedefs(bool mark)
{
List<Linedef> list = new List<Linedef>(linedefs.Count >> 1);
foreach(Linedef l in linedefs) if(l.Marked == mark) list.Add(l);
return list;
}
// Returns a collection of sectors that match a marked state
public ICollection<Sector> GetMarkedSectors(bool mark)
{
List<Sector> list = new List<Sector>(sectors.Count >> 1);
foreach(Sector s in sectors) if(s.Marked == mark) list.Add(s);
return list;
}
// This creates a marking from selection
public void MarkSelectedVertices(bool selected, bool mark)
{
foreach(Vertex v in vertices) if(v.Selected == selected) v.Marked |= mark;
}
// This creates a marking from selection
public void MarkSelectedLinedefs(bool selected, bool mark)
{
foreach(Linedef l in linedefs) if(l.Selected == selected) l.Marked |= mark;
}
// This creates a marking from selection
public void MarkSelectedSectors(bool selected, bool mark)
{
foreach(Sector s in sectors) if(s.Selected == selected) s.Marked |= mark;
}
// This creates a marking from selection
public void MarkSelectedThings(bool selected, bool mark)
{
foreach(Thing t in things) if(t.Selected == selected) t.Marked |= mark;
}
/// <summary>
/// Returns a collection of vertices that match a marked state on the linedefs
/// </summary>
public ICollection<Vertex> GetVerticesFromLinesMarks(bool mark)
{
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
foreach(Vertex v in vertices)
{
foreach(Linedef l in v.Linedefs)
{
if(l.Marked == mark)
{
list.Add(v);
break;
}
}
}
return list;
}
/// <summary>
/// Returns a collection of vertices that match a marked state on the linedefs
/// The difference with GetVerticesFromLinesMarks is that in this method
/// ALL linedefs of a vertex must match the specified marked state.
/// </summary>
public ICollection<Vertex> GetVerticesFromAllLinesMarks(bool mark)
{
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
foreach(Vertex v in vertices)
{
bool qualified = true;
foreach(Linedef l in v.Linedefs)
{
if(l.Marked != mark)
{
qualified = false;
break;
}
}
if(qualified) list.Add(v);
}
return list;
}
/// <summary>
/// Returns a collection of vertices that match a marked state on the linedefs
/// </summary>
public ICollection<Vertex> GetVerticesFromSectorsMarks(bool mark)
{
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
foreach(Vertex v in vertices)
{
foreach(Linedef l in v.Linedefs)
{
if(((l.Front != null) && (l.Front.Sector.Marked == mark)) ||
((l.Back != null) && (l.Back.Sector.Marked == mark)))
{
list.Add(v);
break;
}
}
}
return list;
}
#endregion
#region ================== Areas #region ================== Areas
// This creates an area from vertices // This creates an area from vertices
@ -612,26 +703,32 @@ namespace CodeImp.DoomBuilder.Map
#region ================== Stitching #region ================== Stitching
// This stitches geometry /// <summary>
public int StitchGeometry(ICollection<Vertex> movingverts, ICollection<Vertex> fixedverts) /// Stitches marked geometry with non-marked geometry. Returns the number of stitches made.
/// </summary>
public int StitchGeometry()
{ {
ICollection<Linedef> movinglines; ICollection<Linedef> movinglines;
ICollection<Linedef> fixedlines; ICollection<Linedef> fixedlines;
ICollection<Vertex> nearbyfixedverts; ICollection<Vertex> nearbyfixedverts;
ICollection<Vertex> movingverts;
ICollection<Vertex> fixedverts;
Rectangle editarea; Rectangle editarea;
int stitches = 0; int stitches = 0;
int stitchundo; int stitchundo;
if(General.MainWindow.AutoMerge) // Find vertices
{ movingverts = General.Map.Map.GetMarkedVertices(true);
fixedverts = General.Map.Map.GetMarkedVertices(false);
// Make undo for the stitching // Make undo for the stitching
stitchundo = General.Map.UndoRedo.CreateUndo("stitch geometry", UndoGroup.None, 0); stitchundo = General.Map.UndoRedo.CreateUndo("stitch geometry", UndoGroup.None, 0);
// Find lines that moved during the drag // Find lines that moved during the drag
movinglines = LinedefsFromSelectedVertices(false, true, true); movinglines = LinedefsFromMarkedVertices(false, true, true);
// Find all non-moving lines // Find all non-moving lines
fixedlines = LinedefsFromSelectedVertices(true, false, false); fixedlines = LinedefsFromMarkedVertices(true, false, false);
// Determine area in which we are editing // Determine area in which we are editing
editarea = MapSet.CreateArea(movinglines); editarea = MapSet.CreateArea(movinglines);
@ -660,7 +757,6 @@ namespace CodeImp.DoomBuilder.Map
// No stitching done? then withdraw undo // No stitching done? then withdraw undo
if(stitches == 0) General.Map.UndoRedo.WithdrawUndo(stitchundo); if(stitches == 0) General.Map.UndoRedo.WithdrawUndo(stitchundo);
}
return stitches; return stitches;
} }
@ -1105,9 +1201,9 @@ namespace CodeImp.DoomBuilder.Map
return null; return null;
} }
// This makes a list of lines related to vertex selection // This makes a list of lines related to marked vertices
// A line is unstable when one vertex is selected and the other isn't. // A line is unstable when one vertex is marked and the other isn't.
public ICollection<Linedef> LinedefsFromSelectedVertices(bool includeunselected, bool includestable, bool includeunstable) public ICollection<Linedef> LinedefsFromMarkedVertices(bool includeunselected, bool includestable, bool includeunstable)
{ {
List<Linedef> list = new List<Linedef>((linedefs.Count / 2) + 1); List<Linedef> list = new List<Linedef>((linedefs.Count / 2) + 1);
@ -1115,9 +1211,9 @@ namespace CodeImp.DoomBuilder.Map
foreach(Linedef l in linedefs) foreach(Linedef l in linedefs)
{ {
// Check if this is to be included // Check if this is to be included
if((includestable && (l.Start.Selected && l.End.Selected)) || if((includestable && (l.Start.Marked && l.End.Marked)) ||
(includeunstable && (l.Start.Selected ^ l.End.Selected)) || (includeunstable && (l.Start.Marked ^ l.End.Marked)) ||
(includeunselected && (!l.Start.Selected && !l.End.Selected)) ) (includeunselected && (!l.Start.Marked && !l.End.Marked)))
{ {
// Add to list // Add to list
list.Add(l); list.Add(l);

View file

@ -63,6 +63,7 @@ namespace CodeImp.DoomBuilder.Map
// Selections // Selections
private bool selected; private bool selected;
private bool marked;
// Cloning // Cloning
private Sector clone; private Sector clone;
@ -96,6 +97,7 @@ namespace CodeImp.DoomBuilder.Map
public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } } public int Tag { get { return tag; } set { tag = value; if((tag < 0) || (tag > MapSet.HIGHEST_TAG)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } }
public int Brightness { get { return brightness; } set { brightness = value; } } public int Brightness { get { return brightness; } set { brightness = value; } }
public bool Selected { get { return selected; } set { selected = value; } } public bool Selected { get { return selected; } set { selected = value; } }
public bool Marked { get { return marked; } set { marked = value; } }
public bool UpdateNeeded { get { return updateneeded; } set { updateneeded |= value; } } public bool UpdateNeeded { get { return updateneeded; } set { updateneeded |= value; } }
public Sector Clone { get { return clone; } set { clone = value; } } public Sector Clone { get { return clone; } set { clone = value; } }
public TriangleList Triangles { get { return triangles; } set { triangles = value; } } public TriangleList Triangles { get { return triangles; } set { triangles = value; } }

View file

@ -68,6 +68,7 @@ namespace CodeImp.DoomBuilder.Map
// Selections // Selections
private bool selected; private bool selected;
private bool marked;
// Additional fields // Additional fields
private SortedList<string, object> fields; private SortedList<string, object> fields;
@ -89,6 +90,7 @@ namespace CodeImp.DoomBuilder.Map
public int Action { get { return action; } } public int Action { get { return action; } }
public byte[] Args { get { return args; } } public byte[] Args { get { return args; } }
public bool Selected { get { return selected; } set { selected = value; } } public bool Selected { get { return selected; } set { selected = value; } }
public bool Marked { get { return marked; } set { marked = value; } }
public float Size { get { return size; } } public float Size { get { return size; } }
public float IconOffset { get { return iconoffset; } } public float IconOffset { get { return iconoffset; } }
public PixelColor Color { get { return color; } } public PixelColor Color { get { return color; } }

View file

@ -56,6 +56,7 @@ namespace CodeImp.DoomBuilder.Map
// Selections // Selections
private bool selected; private bool selected;
private bool marked;
// Cloning // Cloning
private Vertex clone; private Vertex clone;
@ -77,6 +78,7 @@ namespace CodeImp.DoomBuilder.Map
public int Y { get { return y; } } public int Y { get { return y; } }
public bool IsDisposed { get { return isdisposed; } } public bool IsDisposed { get { return isdisposed; } }
public bool Selected { get { return selected; } set { selected = value; } } public bool Selected { get { return selected; } set { selected = value; } }
public bool Marked { get { return marked; } set { marked = value; } }
public Vertex Clone { get { return clone; } set { clone = value; } } public Vertex Clone { get { return clone; } set { clone = value; } }
public SortedList<string, object> Fields { get { return fields; } } public SortedList<string, object> Fields { get { return fields; } }
@ -248,6 +250,7 @@ namespace CodeImp.DoomBuilder.Map
// If either of the two vertices was selected, keep the other selected // If either of the two vertices was selected, keep the other selected
if(this.selected) other.selected = true; if(this.selected) other.selected = true;
if(this.marked) other.marked = true;
// Remove this vertex // Remove this vertex
this.Dispose(); this.Dispose();