Speed up linedef processing by not relying on a hashmap

This commit is contained in:
Magnus Norddahl 2019-12-20 05:12:39 +01:00 committed by spherallic
parent e44debce82
commit 026324779e
2 changed files with 17 additions and 9 deletions

View file

@ -77,6 +77,9 @@ namespace CodeImp.DoomBuilder.Map
// Clone
private int serializedindex;
// Rendering
private int lastProcessed;
#endregion
@ -111,7 +114,8 @@ namespace CodeImp.DoomBuilder.Map
public RectangleF Rect { get { return rect; } }
public int[] Args { get { return args; } }
internal int SerializedIndex { get { return serializedindex; } set { serializedindex = value; } }
internal bool FrontInterior { get { return frontinterior; } set { frontinterior = value; } }
internal int LastProcessed { get { return lastProcessed; } set { lastProcessed = value; } }
internal bool FrontInterior { get { return frontinterior; } set { frontinterior = value; } }
internal bool ImpassableFlag { get { return impassableflag; } }
internal int ColorPresetIndex { get { return colorPresetIndex; } } //mxd
internal bool ExtraFloorFlag; //mxd

View file

@ -510,15 +510,18 @@ namespace CodeImp.DoomBuilder.VisualModes
//mxd. Should move selected things in specified direction
protected virtual void MoveSelectedThings(Vector2D direction, bool absolutePosition) { }
#endregion
#region ================== Visibility Culling
#endregion
#region ================== Visibility Culling
int lastProcessed = 0;
// This preforms visibility culling
protected void DoCulling()
{
HashSet<Linedef> visiblelines = new HashSet<Linedef>();
lastProcessed++;
List<Linedef> visiblelines = new List<Linedef>();
Vector2D campos2d = General.Map.VisualCamera.Position;
// Make collections
@ -538,10 +541,11 @@ namespace CodeImp.DoomBuilder.VisualModes
foreach(Linedef ld in block.Lines)
{
// Line not already processed?
if(!visiblelines.Contains(ld))
if (ld.LastProcessed != lastProcessed)//if(!visiblelines.Contains(ld))
{
// Add line if not added yet
visiblelines.Add(ld);
// Add line if not added yet
ld.LastProcessed = lastProcessed;
visiblelines.Add(ld);
// Which side of the line is the camera on?
if(ld.SideOfLine(campos2d) < 0)