mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-04-25 03:51:01 +00:00
@ Changed the MapSet to work with arrays instead of linkedlists. Because the index is now know for each element and can be retrieved in O(1) efficiency it has become a property (Index) for all map elements. GetIndexFor* functions have been removed. Get*ByIndex are now also of O(1) efficiency.
This commit is contained in:
parent
45ad5f5943
commit
f09bfff419
34 changed files with 461 additions and 408 deletions
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{818B3D10-F791-4C3F-9AF5-BB2D0079B63C}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
|
@ -676,6 +676,7 @@
|
|||
<Compile Include="General\ErrorLogger.cs" />
|
||||
<Compile Include="IO\DoomColormapReader.cs" />
|
||||
<Compile Include="Map\SelectionType.cs" />
|
||||
<Compile Include="Map\MapElementCollection.cs" />
|
||||
<Compile Include="Rendering\SurfaceBufferSet.cs" />
|
||||
<Compile Include="Rendering\SurfaceEntry.cs" />
|
||||
<Compile Include="Rendering\SurfaceManager.cs" />
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
peggedness = "None";
|
||||
|
||||
// Linedef info
|
||||
infopanel.Text = " Linedef " + l.Map.GetIndexForLinedef(l) + " ";
|
||||
infopanel.Text = " Linedef " + l.Index + " ";
|
||||
action.Text = act.ToString();
|
||||
length.Text = l.Length.ToString("0.##");
|
||||
angle.Text = l.AngleDeg.ToString() + "\u00B0";
|
||||
|
@ -145,7 +145,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(l.Front != null)
|
||||
{
|
||||
// Show sidedef info
|
||||
frontpanel.Text = " Front Sidedef " + l.Map.GetIndexForSidedef(l.Front) + " ";
|
||||
frontpanel.Text = " Front Sidedef " + l.Index + " ";
|
||||
frontoffset.Text = l.Front.OffsetX + ", " + l.Front.OffsetY;
|
||||
fronthighname.Text = l.Front.HighTexture;
|
||||
frontmidname.Text = l.Front.MiddleTexture;
|
||||
|
@ -177,7 +177,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(l.Back != null)
|
||||
{
|
||||
// Show sidedef info
|
||||
backpanel.Text = " Back Sidedef " + l.Map.GetIndexForSidedef(l.Back) + " ";
|
||||
backpanel.Text = " Back Sidedef " + l.Index + " ";
|
||||
backoffset.Text = l.Back.OffsetX + ", " + l.Back.OffsetY;
|
||||
backhighname.Text = l.Back.HighTexture;
|
||||
backmidname.Text = l.Back.MiddleTexture;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
effectinfo = s.Effect.ToString() + " - Unknown";
|
||||
|
||||
// Sector info
|
||||
sectorinfo.Text = " Sector " + s.Map.GetIndexForSector(s) + " ";
|
||||
sectorinfo.Text = " Sector " + s.Index + " ";
|
||||
effect.Text = effectinfo;
|
||||
ceiling.Text = s.CeilHeight.ToString();
|
||||
floor.Text = s.FloorHeight.ToString();
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
}
|
||||
|
||||
// Thing info
|
||||
infopanel.Text = " Thing " + t.Map.GetIndexForThing(t) + " ";
|
||||
infopanel.Text = " Thing " + t.Index + " ";
|
||||
type.Text = t.Type + " - " + ti.Title;
|
||||
action.Text = actioninfo;
|
||||
position.Text = t.Position.x.ToString() + ", " + t.Position.y.ToString() + ", " + zinfo;
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
public void ShowInfo(Vertex v)
|
||||
{
|
||||
// Vertex info
|
||||
vertexinfo.Text = " Vertex " + v.Map.GetIndexForVertex(v) + " ";
|
||||
vertexinfo.Text = " Vertex " + v.Index + " ";
|
||||
position.Text = v.Position.x.ToString("0.##") + ", " + v.Position.y.ToString("0.##");
|
||||
|
||||
// Show the whole thing
|
||||
|
|
|
@ -344,6 +344,7 @@ namespace CodeImp.DoomBuilder
|
|||
mapwad.Dispose();
|
||||
|
||||
// Read the map from temp file
|
||||
map.BeginAddRemove();
|
||||
General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
|
||||
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
|
||||
General.WriteLogLine("Reading map data structures from file...");
|
||||
|
@ -354,6 +355,7 @@ namespace CodeImp.DoomBuilder
|
|||
General.ShowErrorMessage("Unable to read the map data structures with the specified configuration.", MessageBoxButtons.OK);
|
||||
return false;
|
||||
}
|
||||
map.EndAddRemove();
|
||||
|
||||
// Load data manager
|
||||
General.WriteLogLine("Loading data resources...");
|
||||
|
|
|
@ -923,7 +923,9 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
}
|
||||
|
||||
// Join merge vertices so that overlapping vertices in the draw become one.
|
||||
map.BeginAddRemove();
|
||||
MapSet.JoinVertices(mergeverts, mergeverts, false, MapSet.STITCH_DISTANCE);
|
||||
map.EndAddRemove();
|
||||
|
||||
/***************************************************\
|
||||
Find a way to close the drawing
|
||||
|
@ -1157,8 +1159,10 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
// Merge intersetion vertices with the new lines. This completes the
|
||||
// self intersections for which splits were made above.
|
||||
map.Update(true, false);
|
||||
map.BeginAddRemove();
|
||||
MapSet.SplitLinesByVertices(newlines, intersectverts, MapSet.STITCH_DISTANCE, null);
|
||||
MapSet.SplitLinesByVertices(newlines, mergeverts, MapSet.STITCH_DISTANCE, null);
|
||||
map.EndAddRemove();
|
||||
|
||||
/***************************************************\
|
||||
Determine drawing interior
|
||||
|
|
|
@ -129,6 +129,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
reader = new BinaryReader(mem);
|
||||
|
||||
// Read items from the lump
|
||||
map.SetCapacity(0, 0, 0, 0, num);
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
// Read properties from stream
|
||||
|
@ -178,6 +179,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
link = new Dictionary<int, Vertex>(num);
|
||||
|
||||
// Read items from the lump
|
||||
map.SetCapacity(num, 0, 0, 0, 0);
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
// Read properties from stream
|
||||
|
@ -222,6 +224,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
link = new Dictionary<int, Sector>(num);
|
||||
|
||||
// Read items from the lump
|
||||
map.SetCapacity(0, 0, 0, num, 0);
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
// Read properties from stream
|
||||
|
@ -255,7 +258,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
MemoryStream linedefsmem, sidedefsmem;
|
||||
BinaryReader readline, readside;
|
||||
Lump linedefslump, sidedefslump;
|
||||
int num, i, offsetx, offsety, v1, v2;
|
||||
int num, numsides, i, offsetx, offsety, v1, v2;
|
||||
int s1, s2, flags, action, tag, sc;
|
||||
Dictionary<string, bool> stringflags;
|
||||
string thigh, tmid, tlow;
|
||||
|
@ -274,10 +277,12 @@ namespace CodeImp.DoomBuilder.IO
|
|||
linedefsmem = new MemoryStream(linedefslump.Stream.ReadAllBytes());
|
||||
sidedefsmem = new MemoryStream(sidedefslump.Stream.ReadAllBytes());
|
||||
num = (int)linedefslump.Stream.Length / 14;
|
||||
numsides = (int)sidedefslump.Stream.Length / 30;
|
||||
readline = new BinaryReader(linedefsmem);
|
||||
readside = new BinaryReader(sidedefsmem);
|
||||
|
||||
// Read items from the lump
|
||||
map.SetCapacity(0, num, numsides, 0, 0);
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
// Read properties from stream
|
||||
|
|
|
@ -131,6 +131,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
reader = new BinaryReader(mem);
|
||||
|
||||
// Read items from the lump
|
||||
map.SetCapacity(0, 0, 0, 0, num);
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
// Read properties from stream
|
||||
|
@ -188,6 +189,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
link = new Dictionary<int, Vertex>(num);
|
||||
|
||||
// Read items from the lump
|
||||
map.SetCapacity(num, 0, 0, 0, 0);
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
// Read properties from stream
|
||||
|
@ -232,6 +234,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
link = new Dictionary<int, Sector>(num);
|
||||
|
||||
// Read items from the lump
|
||||
map.SetCapacity(0, 0, 0, num, 0);
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
// Read properties from stream
|
||||
|
@ -265,7 +268,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
MemoryStream linedefsmem, sidedefsmem;
|
||||
BinaryReader readline, readside;
|
||||
Lump linedefslump, sidedefslump;
|
||||
int num, i, offsetx, offsety, v1, v2;
|
||||
int num, numsides, i, offsetx, offsety, v1, v2;
|
||||
int s1, s2, flags, action, sc;
|
||||
int[] args = new int[Linedef.NUM_ARGS];
|
||||
Dictionary<string, bool> stringflags;
|
||||
|
@ -285,10 +288,12 @@ namespace CodeImp.DoomBuilder.IO
|
|||
linedefsmem = new MemoryStream(linedefslump.Stream.ReadAllBytes());
|
||||
sidedefsmem = new MemoryStream(sidedefslump.Stream.ReadAllBytes());
|
||||
num = (int)linedefslump.Stream.Length / 16;
|
||||
numsides = (int)sidedefslump.Stream.Length / 30;
|
||||
readline = new BinaryReader(linedefsmem);
|
||||
readside = new BinaryReader(sidedefsmem);
|
||||
|
||||
// Read items from the lump
|
||||
map.SetCapacity(0, num, numsides, 0, 0);
|
||||
for(i = 0; i < num; i++)
|
||||
{
|
||||
// Read properties from stream
|
||||
|
|
|
@ -150,6 +150,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
List<UniversalCollection> collections = GetNamedCollections(textmap.Root, "thing");
|
||||
|
||||
// Go for all collections
|
||||
map.SetCapacity(0, 0, 0, 0, collections.Count);
|
||||
for(int i = 0; i < collections.Count; i++)
|
||||
{
|
||||
// Read fields
|
||||
|
@ -196,6 +197,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
List<UniversalCollection> sidescolls = GetNamedCollections(textmap.Root, "sidedef");
|
||||
|
||||
// Go for all lines
|
||||
map.SetCapacity(0, linescolls.Count, sidescolls.Count, 0, 0);
|
||||
for(int i = 0; i < linescolls.Count; i++)
|
||||
{
|
||||
// Read fields
|
||||
|
@ -308,6 +310,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
link = new Dictionary<int, Sector>(collections.Count);
|
||||
|
||||
// Go for all collections
|
||||
map.SetCapacity(0, 0, 0, collections.Count, 0);
|
||||
for(int i = 0; i < collections.Count; i++)
|
||||
{
|
||||
// Read fields
|
||||
|
@ -347,6 +350,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
link = new Dictionary<int, Vertex>(collections.Count);
|
||||
|
||||
// Go for all collections
|
||||
map.SetCapacity(collections.Count, 0, 0, 0, 0);
|
||||
for(int i = 0; i < collections.Count; i++)
|
||||
{
|
||||
// Read fields
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private MapSet map;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Linedef> mainlistitem;
|
||||
private LinkedListNode<Linedef> startvertexlistitem;
|
||||
private LinkedListNode<Linedef> endvertexlistitem;
|
||||
private LinkedListNode<Linedef> selecteditem;
|
||||
|
@ -109,11 +108,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
internal Linedef(MapSet map, LinkedListNode<Linedef> listitem, Vertex start, Vertex end)
|
||||
internal Linedef(MapSet map, int listindex, Vertex start, Vertex end)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.updateneeded = true;
|
||||
|
@ -129,11 +128,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
// Constructor
|
||||
internal Linedef(MapSet map, LinkedListNode<Linedef> listitem, Vertex start, Vertex end, IReadWriteStream stream)
|
||||
internal Linedef(MapSet map, int listindex, Vertex start, Vertex end, IReadWriteStream stream)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.updateneeded = true;
|
||||
|
@ -159,7 +158,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
isdisposed = true;
|
||||
|
||||
// Remove from main list
|
||||
mainlistitem.List.Remove(mainlistitem);
|
||||
map.RemoveLinedef(listindex);
|
||||
|
||||
// Detach from vertices
|
||||
start.DetachLinedef(startvertexlistitem);
|
||||
|
@ -172,7 +171,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(back != null) back.Dispose();
|
||||
|
||||
// Clean up
|
||||
mainlistitem = null;
|
||||
start = null;
|
||||
end = null;
|
||||
front = null;
|
||||
|
@ -222,14 +220,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
for(int i = 0; i < NUM_ARGS; i++) s.rwInt(ref args[i]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of this linedef. This is a O(n) operation.
|
||||
/// </summary>
|
||||
public int GetIndex()
|
||||
{
|
||||
return map.GetIndexForLinedef(this);
|
||||
}
|
||||
|
||||
// This sets new start vertex
|
||||
public void SetStartVertex(Vertex v)
|
||||
{
|
||||
|
@ -941,7 +931,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// String representation
|
||||
public override string ToString()
|
||||
{
|
||||
return "Linedef " + GetIndex();
|
||||
return "Linedef " + listindex;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -39,6 +39,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Variables
|
||||
|
||||
// List index
|
||||
protected int listindex;
|
||||
|
||||
// Univeral fields
|
||||
private UniFields fields;
|
||||
|
||||
|
@ -52,6 +55,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
public int Index { get { return listindex; } internal set { listindex = value; } }
|
||||
public UniFields Fields { get { return fields; } }
|
||||
public bool Marked { get { return marked; } set { marked = value; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
|
82
Source/Core/Map/MapElementCollection.cs
Normal file
82
Source/Core/Map/MapElementCollection.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
|
||||
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
* This program is released under GNU General Public License
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
public sealed class MapElementCollection<T> : ICollection<T> where T: MapElement
|
||||
{
|
||||
// Members
|
||||
private int numitems;
|
||||
private T[] array;
|
||||
|
||||
// Constructor
|
||||
public MapElementCollection(ref T[] array, int numitems)
|
||||
{
|
||||
this.numitems = numitems;
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
public void Add(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool Contains(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex)
|
||||
{
|
||||
this.array.CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
public int Count { get { return numitems; } }
|
||||
|
||||
public bool IsReadOnly { get { return true; } }
|
||||
|
||||
public bool Remove(T item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator()
|
||||
{
|
||||
throw new NotSupportedException("This array is locked for modification and cannot currently be enumerated.");
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
throw new NotSupportedException("This array is locked for modification and cannot currently be enumerated.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,11 +66,17 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private Sidedef[] sidedefindices;
|
||||
|
||||
// Map structures
|
||||
private LinkedList<Vertex> vertices;
|
||||
private LinkedList<Linedef> linedefs;
|
||||
private LinkedList<Sidedef> sidedefs;
|
||||
private LinkedList<Sector> sectors;
|
||||
private LinkedList<Thing> things;
|
||||
private int freezearrays;
|
||||
private Vertex[] vertices;
|
||||
private Linedef[] linedefs;
|
||||
private Sidedef[] sidedefs;
|
||||
private Sector[] sectors;
|
||||
private Thing[] things;
|
||||
private int numvertices;
|
||||
private int numlinedefs;
|
||||
private int numsidedefs;
|
||||
private int numsectors;
|
||||
private int numthings;
|
||||
|
||||
// Selected elements
|
||||
private LinkedList<Vertex> sel_vertices;
|
||||
|
@ -91,19 +97,19 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Properties
|
||||
|
||||
/// <summary>Returns a reference to the list of all vertices.</summary>
|
||||
public ICollection<Vertex> Vertices { get { return vertices; } }
|
||||
public ICollection<Vertex> Vertices { get { if(freezearrays == 0) return vertices; else return new MapElementCollection<Vertex>(ref vertices, numvertices); } }
|
||||
|
||||
/// <summary>Returns a reference to the list of all linedefs.</summary>
|
||||
public ICollection<Linedef> Linedefs { get { return linedefs; } }
|
||||
public ICollection<Linedef> Linedefs { get { if(freezearrays == 0) return linedefs; else return new MapElementCollection<Linedef>(ref linedefs, numlinedefs); } }
|
||||
|
||||
/// <summary>Returns a reference to the list of all sidedefs.</summary>
|
||||
public ICollection<Sidedef> Sidedefs { get { return sidedefs; } }
|
||||
public ICollection<Sidedef> Sidedefs { get { if(freezearrays == 0) return sidedefs; else return new MapElementCollection<Sidedef>(ref sidedefs, numsidedefs); } }
|
||||
|
||||
/// <summary>Returns a reference to the list of all sectors.</summary>
|
||||
public ICollection<Sector> Sectors { get { return sectors; } }
|
||||
public ICollection<Sector> Sectors { get { if(freezearrays == 0) return sectors; else return new MapElementCollection<Sector>(ref sectors, numsectors); } }
|
||||
|
||||
/// <summary>Returns a reference to the list of all things.</summary>
|
||||
public ICollection<Thing> Things { get { return things; } }
|
||||
public ICollection<Thing> Things { get { if(freezearrays == 0) return things; else return new MapElementCollection<Thing>(ref things, numthings); } }
|
||||
|
||||
/// <summary>Indicates if the map is disposed.</summary>
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
|
@ -142,11 +148,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
internal MapSet()
|
||||
{
|
||||
// Initialize
|
||||
vertices = new LinkedList<Vertex>();
|
||||
linedefs = new LinkedList<Linedef>();
|
||||
sidedefs = new LinkedList<Sidedef>();
|
||||
sectors = new LinkedList<Sector>();
|
||||
things = new LinkedList<Thing>();
|
||||
vertices = new Vertex[0];
|
||||
linedefs = new Linedef[0];
|
||||
sidedefs = new Sidedef[0];
|
||||
sectors = new Sector[0];
|
||||
things = new Thing[0];
|
||||
sel_vertices = new LinkedList<Vertex>();
|
||||
sel_linedefs = new LinkedList<Linedef>();
|
||||
sel_sectors = new LinkedList<Sector>();
|
||||
|
@ -162,11 +168,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
internal MapSet(MemoryStream stream)
|
||||
{
|
||||
// Initialize
|
||||
vertices = new LinkedList<Vertex>();
|
||||
linedefs = new LinkedList<Linedef>();
|
||||
sidedefs = new LinkedList<Sidedef>();
|
||||
sectors = new LinkedList<Sector>();
|
||||
things = new LinkedList<Thing>();
|
||||
vertices = new Vertex[0];
|
||||
linedefs = new Linedef[0];
|
||||
sidedefs = new Sidedef[0];
|
||||
sectors = new Sector[0];
|
||||
things = new Thing[0];
|
||||
sel_vertices = new LinkedList<Vertex>();
|
||||
sel_linedefs = new LinkedList<Linedef>();
|
||||
sel_sectors = new LinkedList<Sector>();
|
||||
|
@ -191,26 +197,27 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
// Already set isdisposed so that changes can be prohibited
|
||||
isdisposed = true;
|
||||
BeginAddRemove();
|
||||
|
||||
// Dispose all things
|
||||
list = new ArrayList(things);
|
||||
foreach(Thing t in list) t.Dispose();
|
||||
while((things.Length > 0) && (things[0] != null))
|
||||
things[0].Dispose();
|
||||
|
||||
// Dispose all sectors
|
||||
list = new ArrayList(sectors);
|
||||
foreach(Sector s in list) s.Dispose();
|
||||
while((sectors.Length > 0) && (sectors[0] != null))
|
||||
sectors[0].Dispose();
|
||||
|
||||
// Dispose all sidedefs
|
||||
list = new ArrayList(sidedefs);
|
||||
foreach(Sidedef sd in list) sd.Dispose();
|
||||
while((sidedefs.Length > 0) && (sidedefs[0] != null))
|
||||
sidedefs[0].Dispose();
|
||||
|
||||
// Dispose all linedefs
|
||||
list = new ArrayList(linedefs);
|
||||
foreach(Linedef l in list) l.Dispose();
|
||||
while((linedefs.Length > 0) && (linedefs[0] != null))
|
||||
linedefs[0].Dispose();
|
||||
|
||||
// Dispose all vertices
|
||||
list = new ArrayList(vertices);
|
||||
foreach(Vertex v in list) v.Dispose();
|
||||
while((vertices.Length > 0) && (vertices[0] != null))
|
||||
vertices[0].Dispose();
|
||||
|
||||
// Clean up
|
||||
vertices = null;
|
||||
|
@ -240,6 +247,61 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Management
|
||||
|
||||
// This begins large add/remove operations
|
||||
public void BeginAddRemove()
|
||||
{
|
||||
freezearrays++;
|
||||
}
|
||||
|
||||
// This allocates the arrays to a minimum size so that
|
||||
// a lot of items can be created faster. This function will never
|
||||
// allocate less than the current number of items.
|
||||
public void SetCapacity(int nvertices, int nlinedefs, int nsidedefs, int nsectors, int nthings)
|
||||
{
|
||||
if(freezearrays == 0)
|
||||
throw new Exception("You must call BeginAddRemove before setting the reserved capacity.");
|
||||
|
||||
if(numvertices < nvertices)
|
||||
Array.Resize(ref vertices, nvertices);
|
||||
|
||||
if(numlinedefs < nlinedefs)
|
||||
Array.Resize(ref linedefs, nlinedefs);
|
||||
|
||||
if(numsidedefs < nsidedefs)
|
||||
Array.Resize(ref sidedefs, nsidedefs);
|
||||
|
||||
if(numsectors < nsectors)
|
||||
Array.Resize(ref sectors, nsectors);
|
||||
|
||||
if(numthings < nthings)
|
||||
Array.Resize(ref things, nthings);
|
||||
}
|
||||
|
||||
// This ends add/remove operations and crops the arrays
|
||||
public void EndAddRemove()
|
||||
{
|
||||
if(freezearrays > 0)
|
||||
freezearrays--;
|
||||
|
||||
if(freezearrays == 0)
|
||||
{
|
||||
if(numvertices < vertices.Length)
|
||||
Array.Resize(ref vertices, numvertices);
|
||||
|
||||
if(numlinedefs < linedefs.Length)
|
||||
Array.Resize(ref linedefs, numlinedefs);
|
||||
|
||||
if(numsidedefs < sidedefs.Length)
|
||||
Array.Resize(ref sidedefs, numsidedefs);
|
||||
|
||||
if(numsectors < sectors.Length)
|
||||
Array.Resize(ref sectors, numsectors);
|
||||
|
||||
if(numthings < things.Length)
|
||||
Array.Resize(ref things, numthings);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This makes a deep copy and returns the new MapSet.
|
||||
/// </summary>
|
||||
|
@ -250,6 +312,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Create the map set
|
||||
MapSet newset = new MapSet();
|
||||
newset.BeginAddRemove();
|
||||
|
||||
// Go for all vertices
|
||||
foreach(Vertex v in vertices)
|
||||
|
@ -304,6 +367,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
foreach(Sector s in sectors) s.Clone = null;
|
||||
|
||||
// Return the new set
|
||||
newset.EndAddRemove();
|
||||
return newset;
|
||||
}
|
||||
|
||||
|
@ -314,6 +378,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Create the map set
|
||||
MapSet newset = new MapSet();
|
||||
newset.BeginAddRemove();
|
||||
|
||||
// Get marked geometry
|
||||
ICollection<Vertex> mvertices = GetMarkedVertices(true);
|
||||
|
@ -414,24 +479,20 @@ namespace CodeImp.DoomBuilder.Map
|
|||
foreach(Sector s in sectors) s.Clone = null;
|
||||
|
||||
// Return the new set
|
||||
newset.EndAddRemove();
|
||||
return newset;
|
||||
}
|
||||
|
||||
/// <summary>This creates a new vertex and returns it.</summary>
|
||||
public Vertex CreateVertex(Vector2D pos)
|
||||
{
|
||||
LinkedListNode<Vertex> listitem;
|
||||
Vertex v;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Vertex>(null);
|
||||
|
||||
// Make the vertex
|
||||
v = new Vertex(this, listitem, pos);
|
||||
listitem.Value = v;
|
||||
Vertex v = new Vertex(this, numvertices, pos);
|
||||
|
||||
// Add vertex to the list
|
||||
vertices.AddLast(listitem);
|
||||
ExpandArray(ref vertices, numvertices);
|
||||
vertices[numvertices] = v;
|
||||
numvertices++;
|
||||
|
||||
// Return result
|
||||
return v;
|
||||
|
@ -440,18 +501,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This creates a new vertex from a stream
|
||||
private Vertex CreateVertex(IReadWriteStream stream)
|
||||
{
|
||||
LinkedListNode<Vertex> listitem;
|
||||
Vertex v;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Vertex>(null);
|
||||
|
||||
// Make the vertex
|
||||
v = new Vertex(this, listitem, stream);
|
||||
listitem.Value = v;
|
||||
Vertex v = new Vertex(this, numvertices, stream);
|
||||
|
||||
// Add vertex to the list
|
||||
vertices.AddLast(listitem);
|
||||
ExpandArray(ref vertices, numvertices);
|
||||
vertices[numvertices] = v;
|
||||
numvertices++;
|
||||
|
||||
// Return result
|
||||
return v;
|
||||
|
@ -460,18 +516,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>This creates a new linedef and returns it.</summary>
|
||||
public Linedef CreateLinedef(Vertex start, Vertex end)
|
||||
{
|
||||
LinkedListNode<Linedef> listitem;
|
||||
Linedef l;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Linedef>(null);
|
||||
|
||||
// Make the linedef
|
||||
l = new Linedef(this, listitem, start, end);
|
||||
listitem.Value = l;
|
||||
Linedef l = new Linedef(this, numlinedefs, start, end);
|
||||
|
||||
// Add linedef to the list
|
||||
linedefs.AddLast(listitem);
|
||||
ExpandArray(ref linedefs, numlinedefs);
|
||||
linedefs[numlinedefs] = l;
|
||||
numlinedefs++;
|
||||
|
||||
// Return result
|
||||
return l;
|
||||
|
@ -480,18 +531,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This creates a new linedef from a stream
|
||||
private Linedef CreateLinedef(Vertex start, Vertex end, IReadWriteStream stream)
|
||||
{
|
||||
LinkedListNode<Linedef> listitem;
|
||||
Linedef l;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Linedef>(null);
|
||||
|
||||
// Make the linedef
|
||||
l = new Linedef(this, listitem, start, end, stream);
|
||||
listitem.Value = l;
|
||||
Linedef l = new Linedef(this, numlinedefs, start, end, stream);
|
||||
|
||||
// Add linedef to the list
|
||||
linedefs.AddLast(listitem);
|
||||
ExpandArray(ref linedefs, numlinedefs);
|
||||
linedefs[numlinedefs] = l;
|
||||
numlinedefs++;
|
||||
|
||||
// Return result
|
||||
return l;
|
||||
|
@ -500,18 +546,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>This creates a new sidedef and returns it.</summary>
|
||||
public Sidedef CreateSidedef(Linedef l, bool front, Sector s)
|
||||
{
|
||||
LinkedListNode<Sidedef> listitem;
|
||||
Sidedef sd;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Sidedef>(null);
|
||||
|
||||
// Make the sidedef
|
||||
sd = new Sidedef(this, listitem, l, front, s);
|
||||
listitem.Value = sd;
|
||||
Sidedef sd = new Sidedef(this, numsidedefs, l, front, s);
|
||||
|
||||
// Add sidedef to the list
|
||||
sidedefs.AddLast(listitem);
|
||||
ExpandArray(ref sidedefs, numsidedefs);
|
||||
sidedefs[numsidedefs] = sd;
|
||||
numsidedefs++;
|
||||
|
||||
// Return result
|
||||
return sd;
|
||||
|
@ -520,18 +561,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This creates a new sidedef from a stream
|
||||
private Sidedef CreateSidedef(Linedef l, bool front, Sector s, IReadWriteStream stream)
|
||||
{
|
||||
LinkedListNode<Sidedef> listitem;
|
||||
Sidedef sd;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Sidedef>(null);
|
||||
|
||||
// Make the sidedef
|
||||
sd = new Sidedef(this, listitem, l, front, s, stream);
|
||||
listitem.Value = sd;
|
||||
Sidedef sd = new Sidedef(this, numsidedefs, l, front, s, stream);
|
||||
|
||||
// Add sidedef to the list
|
||||
sidedefs.AddLast(listitem);
|
||||
ExpandArray(ref sidedefs, numsidedefs);
|
||||
sidedefs[numsidedefs] = sd;
|
||||
numsidedefs++;
|
||||
|
||||
// Return result
|
||||
return sd;
|
||||
|
@ -562,18 +598,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This creates a new sector with a specific fixed index
|
||||
private Sector CreateSector(int index)
|
||||
{
|
||||
LinkedListNode<Sector> listitem;
|
||||
Sector s;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Sector>(null);
|
||||
|
||||
// Make the sector
|
||||
s = new Sector(this, listitem, index);
|
||||
listitem.Value = s;
|
||||
Sector s = new Sector(this, numsectors, index);
|
||||
|
||||
// Add sector to the list
|
||||
sectors.AddLast(listitem);
|
||||
ExpandArray(ref sectors, numsectors);
|
||||
sectors[numsectors] = s;
|
||||
numsectors++;
|
||||
|
||||
// Return result
|
||||
return s;
|
||||
|
@ -582,18 +613,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This creates a new sector from a stream
|
||||
private Sector CreateSector(IReadWriteStream stream)
|
||||
{
|
||||
LinkedListNode<Sector> listitem;
|
||||
Sector s;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Sector>(null);
|
||||
|
||||
// Make the sector
|
||||
s = new Sector(this, listitem, stream);
|
||||
listitem.Value = s;
|
||||
Sector s = new Sector(this, numsectors, stream);
|
||||
|
||||
// Add sector to the list
|
||||
sectors.AddLast(listitem);
|
||||
ExpandArray(ref sectors, numsectors);
|
||||
sectors[numsectors] = s;
|
||||
numsectors++;
|
||||
|
||||
// Return result
|
||||
return s;
|
||||
|
@ -602,18 +628,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>This creates a new thing and returns it.</summary>
|
||||
public Thing CreateThing()
|
||||
{
|
||||
LinkedListNode<Thing> listitem;
|
||||
Thing t;
|
||||
|
||||
// Make a list item
|
||||
listitem = new LinkedListNode<Thing>(null);
|
||||
|
||||
// Make the thing
|
||||
t = new Thing(this, listitem);
|
||||
listitem.Value = t;
|
||||
Thing t = new Thing(this, numthings);
|
||||
|
||||
// Add thing to the list
|
||||
things.AddLast(listitem);
|
||||
ExpandArray(ref things, numthings);
|
||||
things[numthings] = t;
|
||||
numthings++;
|
||||
|
||||
// Return result
|
||||
return t;
|
||||
|
@ -625,6 +646,63 @@ namespace CodeImp.DoomBuilder.Map
|
|||
indexholes.Add(index);
|
||||
}
|
||||
|
||||
private void RemoveItem<T>(ref T[] array, int index, ref int counter) where T: MapElement
|
||||
{
|
||||
if(index == (counter - 1))
|
||||
{
|
||||
array[index] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
array[index] = array[counter - 1];
|
||||
array[index].Index = index;
|
||||
array[counter - 1] = null;
|
||||
}
|
||||
|
||||
counter--;
|
||||
|
||||
if(freezearrays == 0)
|
||||
Array.Resize(ref array, counter);
|
||||
}
|
||||
|
||||
internal void RemoveVertex(int index)
|
||||
{
|
||||
RemoveItem(ref vertices, index, ref numvertices);
|
||||
}
|
||||
|
||||
internal void RemoveLinedef(int index)
|
||||
{
|
||||
RemoveItem(ref linedefs, index, ref numlinedefs);
|
||||
}
|
||||
|
||||
internal void RemoveSidedef(int index)
|
||||
{
|
||||
RemoveItem(ref sidedefs, index, ref numsidedefs);
|
||||
}
|
||||
|
||||
internal void RemoveSector(int index)
|
||||
{
|
||||
RemoveItem(ref sectors, index, ref numsectors);
|
||||
}
|
||||
|
||||
internal void RemoveThing(int index)
|
||||
{
|
||||
RemoveItem(ref things, index, ref numthings);
|
||||
}
|
||||
|
||||
// This increases the size of the array to add an item
|
||||
private void ExpandArray<T>(ref T[] array, int numentries)
|
||||
{
|
||||
// Only resize when there are no more free entries
|
||||
if(numentries == array.Length)
|
||||
{
|
||||
if(freezearrays == 0)
|
||||
Array.Resize(ref array, numentries + 1);
|
||||
else
|
||||
Array.Resize(ref array, numentries + 10);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Serialization
|
||||
|
@ -665,7 +743,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This serializes things
|
||||
private void WriteThings(SerializerStream stream)
|
||||
{
|
||||
stream.wInt(things.Count);
|
||||
stream.wInt(numthings);
|
||||
|
||||
// Go for all things
|
||||
foreach(Thing t in things)
|
||||
|
@ -677,7 +755,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This serializes vertices
|
||||
private void WriteVertices(SerializerStream stream)
|
||||
{
|
||||
stream.wInt(vertices.Count);
|
||||
stream.wInt(numvertices);
|
||||
|
||||
// Go for all vertices
|
||||
int index = 0;
|
||||
|
@ -692,7 +770,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This serializes linedefs
|
||||
private void WriteLinedefs(SerializerStream stream)
|
||||
{
|
||||
stream.wInt(linedefs.Count);
|
||||
stream.wInt(numlinedefs);
|
||||
|
||||
// Go for all lines
|
||||
int index = 0;
|
||||
|
@ -711,7 +789,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This serializes sidedefs
|
||||
private void WriteSidedefs(SerializerStream stream)
|
||||
{
|
||||
stream.wInt(sidedefs.Count);
|
||||
stream.wInt(numsidedefs);
|
||||
|
||||
// Go for all sidedefs
|
||||
foreach(Sidedef sd in sidedefs)
|
||||
|
@ -729,7 +807,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This serializes sectors
|
||||
private void WriteSectors(SerializerStream stream)
|
||||
{
|
||||
stream.wInt(sectors.Count);
|
||||
stream.wInt(numsectors);
|
||||
|
||||
// Go for all sectors
|
||||
int index = 0;
|
||||
|
@ -774,7 +852,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
deserializer.End();
|
||||
|
||||
// Make table of sidedef indices
|
||||
sidedefindices = new Sidedef[sidedefs.Count];
|
||||
sidedefindices = new Sidedef[numsidedefs];
|
||||
foreach(Sidedef sd in sidedefs)
|
||||
sidedefindices[sd.SerializedIndex] = sd;
|
||||
|
||||
|
@ -1077,7 +1155,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
else
|
||||
{
|
||||
List<Vertex> list = new List<Vertex>(vertices.Count - sel_vertices.Count);
|
||||
List<Vertex> list = new List<Vertex>(numvertices - sel_vertices.Count);
|
||||
foreach(Vertex v in vertices) if(!v.Selected) list.Add(v);
|
||||
return list;
|
||||
}
|
||||
|
@ -1092,7 +1170,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
else
|
||||
{
|
||||
List<Thing> list = new List<Thing>(things.Count - sel_things.Count);
|
||||
List<Thing> list = new List<Thing>(numthings - sel_things.Count);
|
||||
foreach(Thing t in things) if(!t.Selected) list.Add(t);
|
||||
return list;
|
||||
}
|
||||
|
@ -1107,7 +1185,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
else
|
||||
{
|
||||
List<Linedef> list = new List<Linedef>(linedefs.Count - sel_linedefs.Count);
|
||||
List<Linedef> list = new List<Linedef>(numlinedefs - sel_linedefs.Count);
|
||||
foreach(Linedef l in linedefs) if(!l.Selected) list.Add(l);
|
||||
return list;
|
||||
}
|
||||
|
@ -1128,7 +1206,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
else
|
||||
{
|
||||
List<Sidedef> list = new List<Sidedef>(linedefs.Count - sel_linedefs.Count);
|
||||
List<Sidedef> list = new List<Sidedef>(numlinedefs - sel_linedefs.Count);
|
||||
foreach(Linedef ld in linedefs)
|
||||
{
|
||||
if(!ld.Selected && (ld.Front != null)) list.Add(ld.Front);
|
||||
|
@ -1147,7 +1225,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
else
|
||||
{
|
||||
List<Sector> list = new List<Sector>(sectors.Count - sel_sectors.Count);
|
||||
List<Sector> list = new List<Sector>(numsectors - sel_sectors.Count);
|
||||
foreach(Sector s in sectors) if(!s.Selected) list.Add(s);
|
||||
return list;
|
||||
}
|
||||
|
@ -1313,7 +1391,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>Returns a collection of vertices that match a marked state.</summary>
|
||||
public List<Vertex> GetMarkedVertices(bool mark)
|
||||
{
|
||||
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
|
||||
List<Vertex> list = new List<Vertex>(numvertices >> 1);
|
||||
foreach(Vertex v in vertices) if(v.Marked == mark) list.Add(v);
|
||||
return list;
|
||||
}
|
||||
|
@ -1321,7 +1399,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>Returns a collection of things that match a marked state.</summary>
|
||||
public List<Thing> GetMarkedThings(bool mark)
|
||||
{
|
||||
List<Thing> list = new List<Thing>(things.Count >> 1);
|
||||
List<Thing> list = new List<Thing>(numthings >> 1);
|
||||
foreach(Thing t in things) if(t.Marked == mark) list.Add(t);
|
||||
return list;
|
||||
}
|
||||
|
@ -1329,7 +1407,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>Returns a collection of linedefs that match a marked state.</summary>
|
||||
public List<Linedef> GetMarkedLinedefs(bool mark)
|
||||
{
|
||||
List<Linedef> list = new List<Linedef>(linedefs.Count >> 1);
|
||||
List<Linedef> list = new List<Linedef>(numlinedefs >> 1);
|
||||
foreach(Linedef l in linedefs) if(l.Marked == mark) list.Add(l);
|
||||
return list;
|
||||
}
|
||||
|
@ -1337,7 +1415,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>Returns a collection of sidedefs that match a marked state.</summary>
|
||||
public List<Sidedef> GetMarkedSidedefs(bool mark)
|
||||
{
|
||||
List<Sidedef> list = new List<Sidedef>(sidedefs.Count >> 1);
|
||||
List<Sidedef> list = new List<Sidedef>(numsidedefs >> 1);
|
||||
foreach(Sidedef s in sidedefs) if(s.Marked == mark) list.Add(s);
|
||||
return list;
|
||||
}
|
||||
|
@ -1345,7 +1423,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>Returns a collection of sectors that match a marked state.</summary>
|
||||
public List<Sector> GetMarkedSectors(bool mark)
|
||||
{
|
||||
List<Sector> list = new List<Sector>(sectors.Count >> 1);
|
||||
List<Sector> list = new List<Sector>(numsectors >> 1);
|
||||
foreach(Sector s in sectors) if(s.Marked == mark) list.Add(s);
|
||||
return list;
|
||||
}
|
||||
|
@ -1405,7 +1483,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// </summary>
|
||||
public ICollection<Vertex> GetVerticesFromLinesMarks(bool mark)
|
||||
{
|
||||
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
|
||||
List<Vertex> list = new List<Vertex>(numvertices >> 1);
|
||||
foreach(Vertex v in vertices)
|
||||
{
|
||||
foreach(Linedef l in v.Linedefs)
|
||||
|
@ -1427,7 +1505,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// </summary>
|
||||
public ICollection<Vertex> GetVerticesFromAllLinesMarks(bool mark)
|
||||
{
|
||||
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
|
||||
List<Vertex> list = new List<Vertex>(numvertices >> 1);
|
||||
foreach(Vertex v in vertices)
|
||||
{
|
||||
bool qualified = true;
|
||||
|
@ -1449,7 +1527,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// </summary>
|
||||
public ICollection<Vertex> GetVerticesFromSectorsMarks(bool mark)
|
||||
{
|
||||
List<Vertex> list = new List<Vertex>(vertices.Count >> 1);
|
||||
List<Vertex> list = new List<Vertex>(numvertices >> 1);
|
||||
foreach(Vertex v in vertices)
|
||||
{
|
||||
foreach(Linedef l in v.Linedefs)
|
||||
|
@ -1528,128 +1606,43 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Indexing
|
||||
|
||||
/// <summary>
|
||||
/// Returns the vertex at the specified index. Returns null when index is out of range.
|
||||
/// Returns the vertex at the specified index. Returns null when index is out of range. This is an O(1) operation.
|
||||
/// </summary>
|
||||
public Vertex GetVertexByIndex(int index)
|
||||
{
|
||||
if(index < vertices.Count)
|
||||
return General.GetByIndex<Vertex>(vertices, index);
|
||||
else
|
||||
return null;
|
||||
return index < numvertices ? vertices[index] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the linedef at the specified index. Returns null when index is out of range.
|
||||
/// Returns the linedef at the specified index. Returns null when index is out of range. This is an O(1) operation.
|
||||
/// </summary>
|
||||
public Linedef GetLinedefByIndex(int index)
|
||||
{
|
||||
if(index < linedefs.Count)
|
||||
return General.GetByIndex<Linedef>(linedefs, index);
|
||||
else
|
||||
return null;
|
||||
return index < numlinedefs ? linedefs[index] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the sidedef at the specified index. Returns null when index is out of range.
|
||||
/// Returns the sidedef at the specified index. Returns null when index is out of range. This is an O(1) operation.
|
||||
/// </summary>
|
||||
public Sidedef GetSidedefByIndex(int index)
|
||||
{
|
||||
if(index < sidedefs.Count)
|
||||
return General.GetByIndex<Sidedef>(sidedefs, index);
|
||||
else
|
||||
return null;
|
||||
return index < numsidedefs ? sidedefs[index] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the sector at the specified index. Returns null when index is out of range.
|
||||
/// Returns the sector at the specified index. Returns null when index is out of range. This is an O(1) operation.
|
||||
/// </summary>
|
||||
public Sector GetSectorByIndex(int index)
|
||||
{
|
||||
if(index < sectors.Count)
|
||||
return General.GetByIndex<Sector>(sectors, index);
|
||||
else
|
||||
return null;
|
||||
return index < numsectors ? sectors[index] : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the thing at the specified index. Returns null when index is out of range.
|
||||
/// Returns the thing at the specified index. Returns null when index is out of range. This is an O(1) operation.
|
||||
/// </summary>
|
||||
public Thing GetThingByIndex(int index)
|
||||
{
|
||||
if(index < things.Count)
|
||||
return General.GetByIndex<Thing>(things, index);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the specified vertex. Returns -1 when the vertex is not in this map.
|
||||
/// </summary>
|
||||
public int GetIndexForVertex(Vertex v)
|
||||
{
|
||||
int index = 0;
|
||||
foreach(Vertex vn in vertices)
|
||||
{
|
||||
if(object.ReferenceEquals(vn, v)) return index;
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the specified linedef. Returns -1 when the linedef is not in this map.
|
||||
/// </summary>
|
||||
public int GetIndexForLinedef(Linedef l)
|
||||
{
|
||||
int index = 0;
|
||||
foreach(Linedef ln in linedefs)
|
||||
{
|
||||
if(object.ReferenceEquals(ln, l)) return index;
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the specified sidedef. Returns -1 when the sidedef is not in this map.
|
||||
/// </summary>
|
||||
public int GetIndexForSidedef(Sidedef sd)
|
||||
{
|
||||
int index = 0;
|
||||
foreach(Sidedef sn in sidedefs)
|
||||
{
|
||||
if(object.ReferenceEquals(sn, sd)) return index;
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the specified sector. Returns -1 when the sector is not in this map.
|
||||
/// </summary>
|
||||
public int GetIndexForSector(Sector s)
|
||||
{
|
||||
int index = 0;
|
||||
foreach(Sector sn in sectors)
|
||||
{
|
||||
if(object.ReferenceEquals(sn, s)) return index;
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the specified thing. Returns -1 when the thing is not in this map.
|
||||
/// </summary>
|
||||
public int GetIndexForThing(Thing t)
|
||||
{
|
||||
int index = 0;
|
||||
foreach(Thing tn in things)
|
||||
{
|
||||
if(object.ReferenceEquals(tn, t)) return index;
|
||||
index++;
|
||||
}
|
||||
return -1;
|
||||
return index < numthings ? things[index] : null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1882,11 +1875,15 @@ namespace CodeImp.DoomBuilder.Map
|
|||
editarea.Inflate(1.0f, 1.0f);
|
||||
|
||||
// Join nearby vertices
|
||||
BeginAddRemove();
|
||||
stitches += MapSet.JoinVertices(fixedverts, movingverts, true, MapSet.STITCH_DISTANCE);
|
||||
EndAddRemove();
|
||||
|
||||
// Update cached values of lines because we need their length/angle
|
||||
Update(true, false);
|
||||
|
||||
BeginAddRemove();
|
||||
|
||||
// Split moving lines with unselected vertices
|
||||
nearbyfixedverts = MapSet.FilterByArea(fixedverts, ref editarea);
|
||||
stitches += MapSet.SplitLinesByVertices(movinglines, nearbyfixedverts, MapSet.STITCH_DISTANCE, movinglines);
|
||||
|
@ -1901,6 +1898,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Join overlapping lines
|
||||
stitches += MapSet.JoinOverlappingLines(movinglines);
|
||||
|
||||
EndAddRemove();
|
||||
|
||||
return stitches;
|
||||
}
|
||||
|
||||
|
@ -1912,21 +1911,21 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public int RemoveVirtualSectors()
|
||||
{
|
||||
int count = 0;
|
||||
LinkedListNode<Sector> n = sectors.First;
|
||||
int index = 0;
|
||||
|
||||
// Go for all sectors
|
||||
while(n != null)
|
||||
while(index < numsectors)
|
||||
{
|
||||
LinkedListNode<Sector> nn = n.Next;
|
||||
|
||||
// Remove when virtual
|
||||
if(n.Value.Fields.ContainsKey(VIRTUAL_SECTOR_FIELD))
|
||||
if(sectors[index].Fields.ContainsKey(VIRTUAL_SECTOR_FIELD))
|
||||
{
|
||||
n.Value.Dispose();
|
||||
sectors[index].Dispose();
|
||||
count++;
|
||||
}
|
||||
|
||||
n = nn;
|
||||
else
|
||||
{
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
|
@ -1936,26 +1935,22 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public int RemoveUnusedSectors(bool reportwarnings)
|
||||
{
|
||||
int count = 0;
|
||||
LinkedListNode<Sector> n = sectors.First;
|
||||
int index = numsectors - 1;
|
||||
|
||||
// Go for all sectors
|
||||
int index = 0;
|
||||
while(n != null)
|
||||
while(index >= 0)
|
||||
{
|
||||
LinkedListNode<Sector> nn = n.Next;
|
||||
|
||||
// Remove when unused
|
||||
if(n.Value.Sidedefs.Count == 0)
|
||||
if(sectors[index].Sidedefs.Count == 0)
|
||||
{
|
||||
if(reportwarnings)
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Sector " + index + " was unused and has been removed.");
|
||||
|
||||
n.Value.Dispose();
|
||||
sectors[index].Dispose();
|
||||
count++;
|
||||
}
|
||||
|
||||
index++;
|
||||
n = nn;
|
||||
index--;
|
||||
}
|
||||
|
||||
return count;
|
||||
|
@ -2492,7 +2487,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// A line is unstable when one vertex is marked and the other isn't.</summary>
|
||||
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>((numlinedefs / 2) + 1);
|
||||
|
||||
// Go for all lines
|
||||
foreach(Linedef l in linedefs)
|
||||
|
@ -2592,19 +2587,19 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Note: Only use this for saving, because this messes up the expected data structure horribly.
|
||||
internal void CompressSidedefs()
|
||||
{
|
||||
Dictionary<uint, List<Sidedef>> storedsides = new Dictionary<uint, List<Sidedef>>(sidedefs.Count);
|
||||
int originalsidescount = sidedefs.Count;
|
||||
Dictionary<uint, List<Sidedef>> storedsides = new Dictionary<uint, List<Sidedef>>(numsidedefs);
|
||||
int originalsidescount = numsidedefs;
|
||||
double starttime = General.Clock.GetCurrentTime();
|
||||
|
||||
LinkedListNode<Sidedef> sn = sidedefs.First;
|
||||
while(sn != null)
|
||||
int sn = 0;
|
||||
while(sn < numsidedefs)
|
||||
{
|
||||
Sidedef stored = null;
|
||||
LinkedListNode<Sidedef> nextsn = sn.Next;
|
||||
Sidedef snsd = sidedefs[sn];
|
||||
|
||||
// Check if checksum is stored
|
||||
bool samesidedef = false;
|
||||
uint checksum = sn.Value.GetChecksum();
|
||||
uint checksum = snsd.GetChecksum();
|
||||
bool checksumstored = storedsides.ContainsKey(checksum);
|
||||
if(checksumstored)
|
||||
{
|
||||
|
@ -2612,7 +2607,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
foreach(Sidedef os in othersides)
|
||||
{
|
||||
// They must be in the same sector
|
||||
if(sn.Value.Sector == os.Sector)
|
||||
if(snsd.Sector == os.Sector)
|
||||
{
|
||||
// Check if sidedefs are really the same
|
||||
stored = os;
|
||||
|
@ -2620,7 +2615,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
SerializerStream sidedata = new SerializerStream(sidemem);
|
||||
MemoryStream othermem = new MemoryStream(1024);
|
||||
SerializerStream otherdata = new SerializerStream(othermem);
|
||||
sn.Value.ReadWrite(sidedata);
|
||||
snsd.ReadWrite(sidedata);
|
||||
os.ReadWrite(otherdata);
|
||||
if(sidemem.Length == othermem.Length)
|
||||
{
|
||||
|
@ -2646,41 +2641,41 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(samesidedef)
|
||||
{
|
||||
// Replace with stored sidedef
|
||||
bool isfront = sn.Value.IsFront;
|
||||
sn.Value.Line.DetachSidedef(sn.Value);
|
||||
bool isfront = snsd.IsFront;
|
||||
snsd.Line.DetachSidedef(snsd);
|
||||
if(isfront)
|
||||
sn.Value.Line.AttachFront(stored);
|
||||
snsd.Line.AttachFront(stored);
|
||||
else
|
||||
sn.Value.Line.AttachBack(stored);
|
||||
snsd.Line.AttachBack(stored);
|
||||
|
||||
// Remove the sidedef
|
||||
sn.Value.ChangeSector(null);
|
||||
sidedefs.Remove(sn);
|
||||
snsd.ChangeSector(null);
|
||||
RemoveSidedef(sn);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Store this new one
|
||||
if(checksumstored)
|
||||
{
|
||||
storedsides[checksum].Add(sn.Value);
|
||||
storedsides[checksum].Add(snsd);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Sidedef> newlist = new List<Sidedef>(4);
|
||||
newlist.Add(sn.Value);
|
||||
newlist.Add(snsd);
|
||||
storedsides.Add(checksum, newlist);
|
||||
}
|
||||
}
|
||||
|
||||
// Next
|
||||
sn = nextsn;
|
||||
// Next
|
||||
sn++;
|
||||
}
|
||||
}
|
||||
|
||||
// Output info
|
||||
double endtime = General.Clock.GetCurrentTime();
|
||||
double deltatimesec = (endtime - starttime) / 1000.0d;
|
||||
float ratio = 100.0f - (((float)sidedefs.Count / (float)originalsidescount) * 100.0f);
|
||||
General.WriteLogLine("Sidedefs compressed: " + sidedefs.Count + " remaining out of " + originalsidescount + " (" + ratio.ToString("########0.00") + "%) in " + deltatimesec.ToString("########0.00") + " seconds");
|
||||
float ratio = 100.0f - (((float)numsidedefs / (float)originalsidescount) * 100.0f);
|
||||
General.WriteLogLine("Sidedefs compressed: " + numsidedefs + " remaining out of " + originalsidescount + " (" + ratio.ToString("########0.00") + "%) in " + deltatimesec.ToString("########0.00") + " seconds");
|
||||
}
|
||||
|
||||
// This converts flags and activations to UDMF fields
|
||||
|
@ -2701,15 +2696,14 @@ namespace CodeImp.DoomBuilder.Map
|
|||
/// <summary>This removes unused vertices.</summary>
|
||||
public void RemoveUnusedVertices()
|
||||
{
|
||||
LinkedListNode<Vertex> vn, vc;
|
||||
|
||||
// Go for all vertices
|
||||
vn = vertices.First;
|
||||
while(vn != null)
|
||||
int index = numvertices - 1;
|
||||
while(index >= 0)
|
||||
{
|
||||
vc = vn;
|
||||
vn = vc.Next;
|
||||
if(vc.Value.Linedefs.Count == 0) vertices.Remove(vc);
|
||||
if((vertices[index] != null) && (vertices[index].Linedefs.Count == 0))
|
||||
vertices[index].Dispose();
|
||||
else
|
||||
index--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private MapSet map;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Sector> mainlistitem;
|
||||
private LinkedListNode<Sector> selecteditem;
|
||||
|
||||
// Sidedefs
|
||||
|
@ -109,11 +108,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
internal Sector(MapSet map, LinkedListNode<Sector> listitem, int index)
|
||||
internal Sector(MapSet map, int listindex, int index)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
this.sidedefs = new LinkedList<Sidedef>();
|
||||
this.fixedindex = index;
|
||||
this.floortexname = "-";
|
||||
|
@ -121,19 +120,21 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.longfloortexname = MapSet.EmptyLongName;
|
||||
this.longceiltexname = MapSet.EmptyLongName;
|
||||
this.triangulationneeded = true;
|
||||
this.surfaceentry = new SurfaceEntry(-1, -1, -1);
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Constructor
|
||||
internal Sector(MapSet map, LinkedListNode<Sector> listitem, IReadWriteStream stream)
|
||||
internal Sector(MapSet map, int listindex, IReadWriteStream stream)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
this.sidedefs = new LinkedList<Sidedef>();
|
||||
this.triangulationneeded = true;
|
||||
this.surfaceentry = new SurfaceEntry(-1, -1, -1);
|
||||
|
||||
ReadWrite(stream);
|
||||
|
||||
|
@ -151,7 +152,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
isdisposed = true;
|
||||
|
||||
// Remove from main list
|
||||
mainlistitem.List.Remove(mainlistitem);
|
||||
map.RemoveSector(listindex);
|
||||
|
||||
// Register the index as free
|
||||
map.AddSectorIndexHole(fixedindex);
|
||||
|
@ -164,7 +165,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
General.Map.CRenderer2D.Surfaces.FreeSurfaces(surfaceentry);
|
||||
|
||||
// Clean up
|
||||
mainlistitem = null;
|
||||
sidedefs = null;
|
||||
map = null;
|
||||
|
||||
|
@ -250,14 +250,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
base.CopyPropertiesTo(s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of this sector. This is a O(n) operation.
|
||||
/// </summary>
|
||||
public int GetIndex()
|
||||
{
|
||||
return map.GetIndexForSector(this);
|
||||
}
|
||||
|
||||
// This attaches a sidedef and returns the listitem
|
||||
public LinkedListNode<Sidedef> AttachSidedef(Sidedef sd)
|
||||
{
|
||||
|
@ -506,7 +498,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// String representation
|
||||
public override string ToString()
|
||||
{
|
||||
return "Sector " + GetIndex();
|
||||
return "Sector " + listindex;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -41,7 +41,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private MapSet map;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Sidedef> mainlistitem;
|
||||
private LinkedListNode<Sidedef> sectorlistitem;
|
||||
|
||||
// Owner
|
||||
|
@ -88,11 +87,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
internal Sidedef(MapSet map, LinkedListNode<Sidedef> listitem, Linedef l, bool front, Sector s)
|
||||
internal Sidedef(MapSet map, int listindex, Linedef l, bool front, Sector s)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
this.linedef = l;
|
||||
this.sector = s;
|
||||
this.texnamehigh = "-";
|
||||
|
@ -113,11 +112,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
// Constructor
|
||||
internal Sidedef(MapSet map, LinkedListNode<Sidedef> listitem, Linedef l, bool front, Sector s, IReadWriteStream stream)
|
||||
internal Sidedef(MapSet map, int listindex, Linedef l, bool front, Sector s, IReadWriteStream stream)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
this.linedef = l;
|
||||
this.sector = s;
|
||||
|
||||
|
@ -143,7 +142,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
isdisposed = true;
|
||||
|
||||
// Remove from main list
|
||||
mainlistitem.List.Remove(mainlistitem);
|
||||
map.RemoveSidedef(listindex);
|
||||
|
||||
// Detach from linedef
|
||||
linedef.DetachSidedef(this);
|
||||
|
@ -152,7 +151,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
sector.DetachSidedef(sectorlistitem);
|
||||
|
||||
// Clean up
|
||||
mainlistitem = null;
|
||||
sectorlistitem = null;
|
||||
linedef = null;
|
||||
map = null;
|
||||
|
@ -203,14 +201,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
base.CopyPropertiesTo(s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of this sidedef. This is a O(n) operation.
|
||||
/// </summary>
|
||||
public int GetIndex()
|
||||
{
|
||||
return map.GetIndexForSidedef(this);
|
||||
}
|
||||
|
||||
// This creates a checksum from the sidedef properties
|
||||
// Used for faster sidedefs compression
|
||||
public uint GetChecksum()
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private Sector sector = null;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Thing> mainlistitem;
|
||||
private LinkedListNode<Thing> selecteditem;
|
||||
|
||||
// Properties
|
||||
|
@ -91,11 +90,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
internal Thing(MapSet map, LinkedListNode<Thing> listitem)
|
||||
internal Thing(MapSet map, int listindex)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
this.flags = new Dictionary<string, bool>();
|
||||
this.args = new int[NUM_ARGS];
|
||||
|
||||
|
@ -113,13 +112,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
isdisposed = true;
|
||||
|
||||
// Remove from main list
|
||||
mainlistitem.List.Remove(mainlistitem);
|
||||
map.RemoveThing(listindex);
|
||||
|
||||
// Remove from sector
|
||||
//if(sector != null) sector.DetachThing(sectorlistitem);
|
||||
|
||||
// Clean up
|
||||
mainlistitem = null;
|
||||
map = null;
|
||||
sector = null;
|
||||
|
||||
|
@ -186,14 +184,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
base.CopyPropertiesTo(t);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of the specified thing. This is a O(n) operation.
|
||||
/// </summary>
|
||||
public int GetIndex()
|
||||
{
|
||||
return map.GetIndexForThing(this);
|
||||
}
|
||||
|
||||
// This determines which sector the thing is in and links it
|
||||
public void DetermineSector()
|
||||
{
|
||||
|
|
|
@ -46,7 +46,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private MapSet map;
|
||||
|
||||
// List items
|
||||
private LinkedListNode<Vertex> mainlistitem;
|
||||
private LinkedListNode<Vertex> selecteditem;
|
||||
|
||||
// Position
|
||||
|
@ -74,12 +73,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
internal Vertex(MapSet map, LinkedListNode<Vertex> listitem, Vector2D pos)
|
||||
internal Vertex(MapSet map, int listindex, Vector2D pos)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.linedefs = new LinkedList<Linedef>();
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
this.pos = pos;
|
||||
|
||||
// We have no destructor
|
||||
|
@ -87,12 +86,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
|
||||
// Constructor
|
||||
internal Vertex(MapSet map, LinkedListNode<Vertex> listitem, IReadWriteStream stream)
|
||||
internal Vertex(MapSet map, int listindex, IReadWriteStream stream)
|
||||
{
|
||||
// Initialize
|
||||
this.map = map;
|
||||
this.linedefs = new LinkedList<Linedef>();
|
||||
this.mainlistitem = listitem;
|
||||
this.listindex = listindex;
|
||||
|
||||
ReadWrite(stream);
|
||||
|
||||
|
@ -110,7 +109,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
isdisposed = true;
|
||||
|
||||
// Remove from main list
|
||||
mainlistitem.List.Remove(mainlistitem);
|
||||
map.RemoveVertex(listindex);
|
||||
|
||||
// Dispose the lines that are attached to this vertex
|
||||
// because a linedef cannot exist without 2 vertices.
|
||||
|
@ -118,7 +117,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Clean up
|
||||
linedefs = null;
|
||||
mainlistitem = null;
|
||||
map = null;
|
||||
|
||||
// Dispose base
|
||||
|
@ -178,14 +176,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns the index of this vertex. This is a O(n) operation.
|
||||
/// </summary>
|
||||
public int GetIndex()
|
||||
{
|
||||
return map.GetIndexForVertex(this);
|
||||
}
|
||||
|
||||
// This copies all properties to another thing
|
||||
public void CopyPropertiesTo(Vertex v)
|
||||
{
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
fronthigh.Required = fl.Front.HighRequired();
|
||||
frontmid.Required = fl.Front.MiddleRequired();
|
||||
frontlow.Required = fl.Front.LowRequired();
|
||||
frontsector.Text = fl.Map.GetIndexForSector(fl.Front.Sector).ToString();
|
||||
frontsector.Text = fl.Front.Sector.Index.ToString();
|
||||
frontoffsetx.Text = fl.Front.OffsetX.ToString();
|
||||
frontoffsety.Text = fl.Front.OffsetY.ToString();
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
backhigh.Required = fl.Back.HighRequired();
|
||||
backmid.Required = fl.Back.MiddleRequired();
|
||||
backlow.Required = fl.Back.LowRequired();
|
||||
backsector.Text = fl.Map.GetIndexForSector(fl.Back.Sector).ToString();
|
||||
backsector.Text = fl.Back.Sector.Index.ToString();
|
||||
backoffsetx.Text = fl.Back.OffsetX.ToString();
|
||||
backoffsety.Text = fl.Back.OffsetY.ToString();
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
if(fronthigh.Required != l.Front.HighRequired()) fronthigh.Required = false;
|
||||
if(frontmid.Required != l.Front.MiddleRequired()) frontmid.Required = false;
|
||||
if(frontlow.Required != l.Front.LowRequired()) frontlow.Required = false;
|
||||
if(frontsector.Text != l.Map.GetIndexForSector(l.Front.Sector).ToString()) frontsector.Text = "";
|
||||
if(frontsector.Text != l.Front.Sector.Index.ToString()) frontsector.Text = "";
|
||||
if(frontoffsetx.Text != l.Front.OffsetX.ToString()) frontoffsetx.Text = "";
|
||||
if(frontoffsety.Text != l.Front.OffsetY.ToString()) frontoffsety.Text = "";
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
if(backhigh.Required != l.Back.HighRequired()) backhigh.Required = false;
|
||||
if(backmid.Required != l.Back.MiddleRequired()) backmid.Required = false;
|
||||
if(backlow.Required != l.Back.LowRequired()) backlow.Required = false;
|
||||
if(backsector.Text != l.Map.GetIndexForSector(l.Back.Sector).ToString()) backsector.Text = "";
|
||||
if(backsector.Text != l.Back.Sector.Index.ToString()) backsector.Text = "";
|
||||
if(backoffsetx.Text != l.Back.OffsetX.ToString()) backoffsetx.Text = "";
|
||||
if(backoffsety.Text != l.Back.OffsetY.ToString()) backoffsety.Text = "";
|
||||
if(General.Map.FormatInterface.HasCustomFields) custombackbutton.Visible = true;
|
||||
|
@ -407,7 +407,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
else if(frontside.CheckState == CheckState.Checked)
|
||||
{
|
||||
// Make sure we have a valid sector (make a new one if needed)
|
||||
if(l.Front != null) index = l.Map.GetIndexForSector(l.Front.Sector); else index = -1;
|
||||
if(l.Front != null) index = l.Front.Sector.Index; else index = -1;
|
||||
s = General.Map.Map.GetSectorByIndex(frontsector.GetResult(index));
|
||||
if(s == null) s = General.Map.Map.CreateSector();
|
||||
|
||||
|
@ -434,7 +434,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
else if(backside.CheckState == CheckState.Checked)
|
||||
{
|
||||
// Make sure we have a valid sector (make a new one if needed)
|
||||
if(l.Back != null) index = l.Map.GetIndexForSector(l.Back.Sector); else index = -1;
|
||||
if(l.Back != null) index = l.Back.Sector.Index; else index = -1;
|
||||
s = General.Map.Map.GetSectorByIndex(backsector.GetResult(index));
|
||||
if(s == null) s = General.Map.Map.CreateSector();
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.viewobjects.Add(s);
|
||||
foreach(Vertex vv in v) this.viewobjects.Add(vv);
|
||||
this.description = "This sector is not a closed region and could cause problems with clipping and rendering in the game. The 'leaks' in the sector are indicated by the colored vertices.";
|
||||
this.index = s.Map.GetIndexForSector(s);
|
||||
this.index = s.Index;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -119,14 +119,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) s.SetCeilTexture(replacewith);
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (ceiling)"));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index + " (ceiling)"));
|
||||
}
|
||||
|
||||
if(s.LongFloorTexture == longfind)
|
||||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) s.SetFloorTexture(replacewith);
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (floor)"));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index + " (floor)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,21 +139,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) sd.SetTextureHigh(replacewith);
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", high)"));
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.Index + " (" + side + ", high)"));
|
||||
}
|
||||
|
||||
if(sd.LongMiddleTexture == longfind)
|
||||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) sd.SetTextureMid(replacewith);
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", middle)"));
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.Index + " (" + side + ", middle)"));
|
||||
}
|
||||
|
||||
if(sd.LongLowTexture == longfind)
|
||||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) sd.SetTextureLow(replacewith);
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", low)"));
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.Index + " (" + side + ", low)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -142,9 +142,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Add to list
|
||||
if(!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex() + " (" + info.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex()));
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,9 +125,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Add to list
|
||||
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
|
||||
if(!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex() + " (" + info.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex()));
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,9 +142,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Add to list
|
||||
if(!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex() + " (" + info.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex()));
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,9 +120,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Add to list
|
||||
LinedefActionInfo info = General.Map.Config.GetLinedefActionInfo(l.Action);
|
||||
if(!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex() + " (" + info.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index + " (" + info.Title + ")"));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.GetIndex()));
|
||||
objs.Add(new FindReplaceObject(l, "Linedef " + l.Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,9 +120,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
SectorEffectInfo info = General.Map.Config.GetSectorEffectInfo(s.Effect);
|
||||
if(!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (" + info.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index + " (" + info.Title + ")"));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex()));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,14 +111,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) s.SetCeilTexture(replacewith);
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (ceiling)"));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index + " (ceiling)"));
|
||||
}
|
||||
|
||||
if(s.LongFloorTexture == longfind)
|
||||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) s.SetFloorTexture(replacewith);
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (floor)"));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index + " (floor)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,9 +117,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
SectorEffectInfo info = General.Map.Config.GetSectorEffectInfo(s.Effect);
|
||||
if(!info.IsNull)
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex() + " (" + info.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index + " (" + info.Title + ")"));
|
||||
else
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.GetIndex()));
|
||||
objs.Add(new FindReplaceObject(s, "Sector " + s.Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,21 +112,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) sd.SetTextureHigh(replacewith);
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", high)"));
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.Index + " (" + side + ", high)"));
|
||||
}
|
||||
|
||||
if(sd.LongMiddleTexture == longfind)
|
||||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) sd.SetTextureMid(replacewith);
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", middle)"));
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.Index + " (" + side + ", middle)"));
|
||||
}
|
||||
|
||||
if(sd.LongLowTexture == longfind)
|
||||
{
|
||||
// Replace and add to list
|
||||
if(replacewith != null) sd.SetTextureLow(replacewith);
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.GetIndex() + " (" + side + ", low)"));
|
||||
objs.Add(new FindReplaceObject(sd, "Sidedef " + sd.Index + " (" + side + ", low)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Add to list
|
||||
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.GetIndex() + " (" + ti.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.Index + " (" + ti.Title + ")"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Add to list
|
||||
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.GetIndex() + " (" + ti.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.Index + " (" + ti.Title + ")"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Add to list
|
||||
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.GetIndex() + " (" + ti.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.Index + " (" + ti.Title + ")"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Add to list
|
||||
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.GetIndex() + " (" + ti.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.Index + " (" + ti.Title + ")"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Add to list
|
||||
ThingTypeInfo ti = General.Map.Data.GetThingInfo(t.Type);
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.GetIndex() + " (" + ti.Title + ")"));
|
||||
objs.Add(new FindReplaceObject(t, "Thing " + t.Index + " (" + ti.Title + ")"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue