now it works :)

This commit is contained in:
codeimp 2007-12-07 15:48:32 +00:00
parent 0e819705bf
commit 5a645c19f0
2 changed files with 32 additions and 6 deletions

View file

@ -247,11 +247,6 @@ namespace CodeImp.DoomBuilder.Editing
// ===== BEGIN GEOMETRY STITCHING
// Determine area in which we are editing
editarea = MapSet.AreaFromVertices(selectedverts);
editarea.Inflate((int)Math.Ceiling(General.Settings.StitchDistance),
(int)Math.Ceiling(General.Settings.StitchDistance));
// Make undo for the stitching
stitchundo = General.Map.UndoRedo.CreateUndo("stitch geometry", UndoGroup.None, 0, false);
@ -260,6 +255,11 @@ namespace CodeImp.DoomBuilder.Editing
// Find all non-moving lines
fixedlines = General.Map.Map.LinedefsFromSelectedVertices(true, false, false);
// Determine area in which we are editing
editarea = MapSet.AreaFromLines(movinglines);
editarea.Inflate((int)Math.Ceiling(General.Settings.StitchDistance),
(int)Math.Ceiling(General.Settings.StitchDistance));
// Join nearby vertices
stitches += MapSet.JoinVertices(unselectedverts, selectedverts, true, General.Settings.StitchDistance);

View file

@ -409,6 +409,32 @@ namespace CodeImp.DoomBuilder.Map
// Return a rect
return new Rectangle(l, t, r - l, b - t);
}
// This creates an area from vertices
public static Rectangle AreaFromLines(ICollection<Linedef> lines)
{
int l = int.MaxValue;
int t = int.MaxValue;
int r = int.MinValue;
int b = int.MinValue;
// Go for all vertices
foreach(Linedef ld in lines)
{
// Adjust boundaries by vertices
if(ld.Start.X < l) l = ld.Start.X;
if(ld.Start.X > r) r = ld.Start.X;
if(ld.Start.Y < t) t = ld.Start.Y;
if(ld.Start.Y > b) b = ld.Start.Y;
if(ld.End.X < l) l = ld.End.X;
if(ld.End.X > r) r = ld.End.X;
if(ld.End.Y < t) t = ld.End.Y;
if(ld.End.Y > b) b = ld.End.Y;
}
// Return a rect
return new Rectangle(l, t, r - l, b - t);
}
// This filters lines by a square area
public static ICollection<Linedef> FilterArea(ICollection<Linedef> lines, ref Rectangle area)
@ -419,7 +445,7 @@ namespace CodeImp.DoomBuilder.Map
foreach(Linedef l in lines)
{
// Check the cs field bits
if((GetCSFieldBits(l.Start, ref area) & GetCSFieldBits(l.End, ref area)) != 0)
if((GetCSFieldBits(l.Start, ref area) & GetCSFieldBits(l.End, ref area)) == 0)
{
// The line could be in the area
newlines.Add(l);