some optimizations

This commit is contained in:
codeimp 2008-04-19 15:44:05 +00:00
parent 53fd1fb04c
commit 40f5e853bd
5 changed files with 19 additions and 10 deletions

View file

@ -292,8 +292,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Editing
if(MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest)) if(MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest))
{ {
// Update cached values // Update cached values
//General.Map.Map.Update(true, false); General.Map.Map.Update(true, false);
General.Map.Map.Update();
// Redraw // Redraw
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();

View file

@ -27,6 +27,7 @@ using CodeImp.DoomBuilder.Rendering;
using SlimDX; using SlimDX;
using System.Drawing; using System.Drawing;
using CodeImp.DoomBuilder.Editing; using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.IO;
#endregion #endregion
@ -54,6 +55,9 @@ namespace CodeImp.DoomBuilder.Map
private LinkedList<Sector> sectors; private LinkedList<Sector> sectors;
private LinkedList<Thing> things; private LinkedList<Thing> things;
// Optimization
private long emptylongname;
// Disposing // Disposing
private bool isdisposed = false; private bool isdisposed = false;
@ -67,6 +71,7 @@ namespace CodeImp.DoomBuilder.Map
public ICollection<Sector> Sectors { get { return sectors; } } public ICollection<Sector> Sectors { get { return sectors; } }
public ICollection<Thing> Things { get { return things; } } public ICollection<Thing> Things { get { return things; } }
public bool IsDisposed { get { return isdisposed; } } public bool IsDisposed { get { return isdisposed; } }
public long EmptyLongName { get { return emptylongname; } }
#endregion #endregion
@ -83,6 +88,7 @@ namespace CodeImp.DoomBuilder.Map
things = new LinkedList<Thing>(); things = new LinkedList<Thing>();
indexholes = new List<int>(); indexholes = new List<int>();
lastsectorindex = 0; lastsectorindex = 0;
emptylongname = Lump.MakeLongName("-");
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);

View file

@ -114,8 +114,10 @@ namespace CodeImp.DoomBuilder.Map
this.sidedefs = new LinkedList<Sidedef>(); this.sidedefs = new LinkedList<Sidedef>();
this.things = new LinkedList<Thing>(); this.things = new LinkedList<Thing>();
this.index = index; this.index = index;
SetCeilTexture("-"); this.floortexname = "-";
SetFloorTexture("-"); this.ceiltexname = "-";
this.longfloortexname = map.EmptyLongName;
this.longceiltexname = map.EmptyLongName;
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);

View file

@ -98,9 +98,12 @@ namespace CodeImp.DoomBuilder.Map
this.mainlistitem = listitem; this.mainlistitem = listitem;
this.linedef = l; this.linedef = l;
this.sector = s; this.sector = s;
SetTextureHigh("-"); this.texnamehigh = "-";
SetTextureMid("-"); this.texnamemid = "-";
SetTextureLow("-"); this.texnamelow = "-";
this.longtexnamehigh = map.EmptyLongName;
this.longtexnamemid = map.EmptyLongName;
this.longtexnamelow = map.EmptyLongName;
// Attach to the linedef // Attach to the linedef
if(front) l.AttachFront(this); else l.AttachBack(this); if(front) l.AttachFront(this); else l.AttachBack(this);

View file

@ -181,8 +181,7 @@ namespace CodeImp.DoomBuilder.Map
// This returns the distance from given coordinates // This returns the distance from given coordinates
public float DistanceToSq(Vector2D p) public float DistanceToSq(Vector2D p)
{ {
Vector2D delta = p - pos; return (p.x - pos.x) * (p.x - pos.x) + (p.y - pos.y) * (p.y - pos.y);
return delta.GetLengthSq();
} }
// This returns the distance from given coordinates // This returns the distance from given coordinates