Increased performance when deleting things in Things mode, linedefs in Linedefs mode and sectors in Sectors mode.

Increased performance when canceling Edit mode after pasting.
"Export to Wavefront .obj" function: current selection is now converted to sectors before running the function (previously it would export selected sectors when there were sectors selected, or the whole map when no sectors were selected).
This commit is contained in:
MaxED 2013-12-13 09:31:18 +00:00
parent d03787f48c
commit 1bd58bab4b
8 changed files with 49 additions and 34 deletions

View file

@ -171,6 +171,7 @@ namespace CodeImp.DoomBuilder.IO
private string cpErrorDescription = "";
private int cpErrorLine = 0;
private string cpErrorFile = "";
private char[] space = new[]{ ' ' }; //mxd
// Configuration root
private IDictionary root = null;
@ -297,7 +298,7 @@ namespace CodeImp.DoomBuilder.IO
// This is called by all the ReadSetting overloads to perform the read
private bool CheckSetting(IDictionary dic, string setting, string pathseperator)
{
IDictionary cs = null;
IDictionary cs;
// Split the path in an array
string[] keys = setting.Split(pathseperator.ToCharArray());
@ -312,13 +313,13 @@ namespace CodeImp.DoomBuilder.IO
if(item is IDictionary)
{
// Check if the key is valid
if(ValidateKey(null, keys[i].Trim(), "", -1) == true)
if(ValidateKey(null, keys[i].Trim(), "", -1))
{
// Cast to ConfigStruct
cs = (IDictionary)item;
// Check if the requested item exists
if(cs.Contains(keys[i]) == true)
if(cs.Contains(keys[i]))
{
// Set the item to the next item
item = cs[keys[i]];
@ -351,7 +352,7 @@ namespace CodeImp.DoomBuilder.IO
private object ReadAnySetting(IDictionary dic, string setting, object defaultsetting, string pathseperator) { return ReadAnySetting(dic, "", -1, setting, defaultsetting, pathseperator); }
private object ReadAnySetting(IDictionary dic, string file, int line, string setting, object defaultsetting, string pathseperator)
{
IDictionary cs = null;
IDictionary cs;
// Split the path in an array
string[] keys = setting.Split(pathseperator.ToCharArray());
@ -366,13 +367,13 @@ namespace CodeImp.DoomBuilder.IO
if(item is IDictionary)
{
// Check if the key is valid
if(ValidateKey(null, keys[i].Trim(), file, line) == true)
if(ValidateKey(null, keys[i].Trim(), file, line))
{
// Cast to ConfigStruct
cs = (IDictionary)item;
// Check if the requested item exists
if(cs.Contains(keys[i]) == true)
if(cs.Contains(keys[i]))
{
// Set the item to the next item
item = cs[keys[i]];
@ -449,7 +450,7 @@ namespace CodeImp.DoomBuilder.IO
else
{
// Check if there are spaces in the key
if(key.IndexOfAny(" ".ToCharArray()) > -1)
if(key.IndexOfAny(space) > -1)
{
// ERROR: Spaces not allowed in key names
if(errorline > -1) RaiseError(file, errorline, ERROR_KEYSPACES);
@ -504,7 +505,7 @@ namespace CodeImp.DoomBuilder.IO
else
{
// Check if there are spaces in the key
if(keyword.IndexOfAny(" ".ToCharArray()) > -1)
if(keyword.IndexOfAny(space) > -1)
{
// ERROR: Spaces not allowed in key names
if(errorline > -1) RaiseError(file, errorline, ERROR_ASSIGNINVALID);
@ -798,8 +799,8 @@ namespace CodeImp.DoomBuilder.IO
// Return result depending on the keyword
switch(val.Trim().ToLowerInvariant())
{
case "true": return (bool)true;
case "false": return (bool)false;
case "true": return true;
case "false": return false;
case "null": return null;
default: RaiseError(file, line, ERROR_KEYWORDUNKNOWN + "\nUnrecognized token: '" + val.Trim().ToLowerInvariant() + "'"); return null;
}
@ -964,7 +965,6 @@ namespace CodeImp.DoomBuilder.IO
}
RaiseError(file, line, ERROR_UNEXPECTED_END);
return;
}
@ -1174,7 +1174,7 @@ namespace CodeImp.DoomBuilder.IO
else if(de.Value is bool)
{
// Check value
if((bool)de.Value == true)
if((bool)de.Value)
{
// Output the keyword "true"
db.Append(leveltabs); db.Append(de.Key.ToString()); db.Append(spacing);
@ -1283,13 +1283,13 @@ namespace CodeImp.DoomBuilder.IO
for(int i = 0; i < (keys.Length - 1); i++)
{
// Check if the key is valid
if(ValidateKey(null, keys[i].Trim(), "", -1) == true)
if(ValidateKey(null, keys[i].Trim(), "", -1))
{
// Cast to ConfigStruct
cs = (IDictionary)item;
// Check if the requested item exists
if(cs.Contains(keys[i]) == true)
if(cs.Contains(keys[i]))
{
// Check if the requested item is a ConfigStruct
if(cs[keys[i]] is IDictionary)
@ -1326,7 +1326,7 @@ namespace CodeImp.DoomBuilder.IO
cs = (IDictionary)item;
// Check if the key already exists
if(cs.Contains(finalkey) == true)
if(cs.Contains(finalkey))
{
// Update the value
cs[finalkey] = settingvalue;
@ -1359,13 +1359,13 @@ namespace CodeImp.DoomBuilder.IO
for(int i = 0; i < (keys.Length - 1); i++)
{
// Check if the key is valid
if(ValidateKey(null, keys[i].Trim(), "", -1) == true)
if(ValidateKey(null, keys[i].Trim(), "", -1))
{
// Cast to ConfigStruct
cs = (IDictionary)item;
// Check if the requested item exists
if(cs.Contains(keys[i]) == true)
if(cs.Contains(keys[i]))
{
// Check if the requested item is a ConfigStruct
if(cs[keys[i]] is IDictionary)
@ -1403,7 +1403,7 @@ namespace CodeImp.DoomBuilder.IO
// Arrived at our destination
// Delete the key if the key exists
if(cs.Contains(finalkey) == true)
if(cs.Contains(finalkey))
{
// Key exists, delete it
cs.Remove(finalkey);
@ -1425,7 +1425,7 @@ namespace CodeImp.DoomBuilder.IO
public bool SaveConfiguration(string filename, string newline, bool whitespace)
{
// Kill the file if it exists
if(File.Exists(filename) == true) File.Delete(filename);
if(File.Exists(filename)) File.Delete(filename);
// Open file stream for writing
FileStream fstream = File.OpenWrite(filename);
@ -1457,7 +1457,7 @@ namespace CodeImp.DoomBuilder.IO
public bool LoadConfiguration(string filename, bool sorted)
{
// Check if the file is missing
if(File.Exists(filename) == false)
if(!File.Exists(filename))
{
throw(new FileNotFoundException("File not found \"" + filename + "\"", filename));
}

View file

@ -528,9 +528,9 @@ namespace CodeImp.DoomBuilder.Map
this.offsetx = offsetx;
this.offsety = offsety;
this.flags = new Dictionary<string, bool>(flags); //mxd
SetTextureHigh(thigh);
SetTextureMid(tmid);
SetTextureLow(tlow);
SetTextureHigh(thigh);
}
// This sets texture

View file

@ -1036,14 +1036,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Resume normal undo/redo recording
General.Map.UndoRedo.IgnorePropChanges = false;
// Remove the geometry
//int index = 0;
foreach(Vertex v in selectedvertices)
v.Dispose();
General.Map.Map.BeginAddRemove(); //mxd
//index = 0;
foreach(Thing t in selectedthings)
t.Dispose();
// Remove the geometry
foreach(Vertex v in selectedvertices) v.Dispose();
foreach(Thing t in selectedthings) t.Dispose();
General.Map.Map.EndAddRemove(); //mxd
// Withdraw the undo
if(General.Map.UndoRedo.NextUndo != null)

View file

@ -905,6 +905,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(l.Back != null && l.Back.Sector.Sidedefs.Count < 4 && !toMerge.ContainsKey(l.Back.Sector))
toMerge.Add(l.Back.Sector, new Vector2D(l.Back.Sector.BBox.Location.X + l.Back.Sector.BBox.Width / 2, l.Back.Sector.BBox.Location.Y + l.Back.Sector.BBox.Height / 2));
}
General.Map.Map.BeginAddRemove(); //mxd
// Dispose selected linedefs
foreach(Linedef ld in selected) {
@ -920,6 +922,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd
General.Map.Map.EndAddRemove();
Tools.MergeInvalidSectors(toMerge);
// Update cache values

View file

@ -1420,13 +1420,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.DisplayStatus(StatusType.Action, "Deleted sector.");
}
General.Map.Map.BeginAddRemove(); //mxd
// Dispose selected sectors
foreach(Sector s in selected)
{
// Get all the linedefs
General.Map.Map.ClearMarkedLinedefs(false);
/*General.Map.Map.ClearMarkedLinedefs(false);
foreach(Sidedef sd in s.Sidedefs) sd.Line.Marked = true;
List<Linedef> lines = General.Map.Map.GetMarkedLinedefs(true);
List<Linedef> lines = General.Map.Map.GetMarkedLinedefs(true);*/
//mxd. Get all the linedefs
List<Linedef> lines = new List<Linedef>(s.Sidedefs.Count);
foreach(Sidedef side in s.Sidedefs) lines.Add(side.Line);
// Dispose the sector
s.Dispose();
@ -1471,6 +1477,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
General.Map.Map.EndAddRemove(); //mxd
// Update cache values
General.Map.IsChanged = true;
General.Map.Map.Update();

View file

@ -836,8 +836,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.DisplayStatus(StatusType.Action, "Deleted a thing.");
}
General.Map.Map.BeginAddRemove(); //mxd
// Dispose selected things
foreach(Thing t in selected) t.Dispose();
General.Map.Map.EndAddRemove(); //mxd
// Update cache values
General.Map.IsChanged = true;

View file

@ -849,10 +849,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Make list of selected vertices
ICollection<Vertex> selected = General.Map.Map.GetSelectedVertices(true);
if(selected.Count == 0) {
if(highlighted != null && !highlighted.IsDisposed)
selected.Add(highlighted);
else
return;
if(highlighted == null || highlighted.IsDisposed) return;
selected.Add(highlighted);
}
// Make undo

View file

@ -891,6 +891,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
[BeginAction("exporttoobj")]
private void exportToObj() {
// Convert geometry selection to sectors
General.Map.Map.ConvertSelection(SelectionType.Sectors);
//get sectors
ICollection<Sector> sectors = General.Map.Map.SelectedSectorsCount == 0 ? General.Map.Map.Sectors : General.Map.Map.GetSelectedSectors(true);
if(sectors.Count == 0) {