mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 13:51:40 +00:00
Remove more dictionaries from the render loop
This commit is contained in:
parent
848ff8e771
commit
11aa31452b
5 changed files with 52 additions and 32 deletions
|
@ -87,6 +87,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd. Rendering
|
||||
private Color4 fogcolor;
|
||||
private SectorFogMode fogmode;
|
||||
private int lastProcessed;
|
||||
|
||||
//mxd. Slopes
|
||||
private Vector3D floorslope;
|
||||
|
@ -142,6 +143,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public float FloorSlopeOffset { get { return flooroffset; } set { BeforePropsChange(); flooroffset = value; updateneeded = true; } }
|
||||
public Vector3D CeilSlope { get { return ceilslope; } set { BeforePropsChange(); ceilslope = value; updateneeded = true; } }
|
||||
public float CeilSlopeOffset { get { return ceiloffset; } set { BeforePropsChange(); ceiloffset = value; updateneeded = true; } }
|
||||
internal int LastProcessed { get { return lastProcessed; } set { lastProcessed = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Clone
|
||||
private int serializedindex;
|
||||
|
||||
// Rendering
|
||||
private int lastProcessed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -78,6 +81,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public long LongMiddleTexture { get { return longtexnamemid; } }
|
||||
public long LongLowTexture { get { return longtexnamelow; } }
|
||||
internal int SerializedIndex { get { return serializedindex; } set { serializedindex = value; } }
|
||||
internal int LastProcessed { get { return lastProcessed; } set { lastProcessed = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -86,6 +86,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private bool fixedsize;
|
||||
private bool directional; //mxd. If true, we need to render an arrow
|
||||
|
||||
// Rendering
|
||||
private int lastProcessed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -116,6 +119,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public ThingRenderMode RenderMode { get { return rendermode; } } //mxd
|
||||
public bool IsDirectional { get { return directional; } } //mxd
|
||||
public bool Highlighted { get { return highlighted; } set { highlighted = value; } } //mxd
|
||||
internal int LastProcessed { get { return lastProcessed; } set { lastProcessed = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
protected Dictionary<Thing, VisualThing> allthings;
|
||||
protected Dictionary<Sector, VisualSector> allsectors;
|
||||
protected List<VisualBlockEntry> visibleblocks;
|
||||
protected Dictionary<Thing, VisualThing> visiblethings;
|
||||
protected Dictionary<Sector, VisualSector> visiblesectors;
|
||||
protected List<VisualThing> visiblethings;
|
||||
protected List<VisualSector> visiblesectors;
|
||||
protected List<VisualGeometry> visiblegeometry;
|
||||
|
||||
#endregion
|
||||
|
@ -104,9 +104,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
this.allsectors = new Dictionary<Sector, VisualSector>(General.Map.Map.Sectors.Count);
|
||||
this.allthings = new Dictionary<Thing, VisualThing>(General.Map.Map.Things.Count);
|
||||
this.visibleblocks = new List<VisualBlockEntry>();
|
||||
this.visiblesectors = new Dictionary<Sector, VisualSector>(50);
|
||||
this.visiblesectors = new List<VisualSector>(50);
|
||||
this.visiblegeometry = new List<VisualGeometry>(200);
|
||||
this.visiblethings = new Dictionary<Thing, VisualThing>(100);
|
||||
this.visiblethings = new List<VisualThing>(100);
|
||||
this.processgeometry = true;
|
||||
this.processthings = true;
|
||||
this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd
|
||||
|
@ -518,9 +518,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
Vector2D campos2d = General.Map.VisualCamera.Position;
|
||||
|
||||
// Make collections
|
||||
visiblesectors = new Dictionary<Sector, VisualSector>(visiblesectors.Count);
|
||||
visiblegeometry = new List<VisualGeometry>(visiblegeometry.Capacity);
|
||||
visiblethings = new Dictionary<Thing, VisualThing>(visiblethings.Count);
|
||||
visiblesectors = new List<VisualSector>(visiblesectors.Count * 2);
|
||||
visiblegeometry = new List<VisualGeometry>(visiblegeometry.Count * 2);
|
||||
visiblethings = new List<VisualThing>(visiblethings.Count * 2);
|
||||
|
||||
// Get the blocks within view range
|
||||
visibleblocks = blockmap.GetFrustumRange(renderer.Frustum2D);
|
||||
|
@ -534,7 +534,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
foreach(Linedef ld in block.Lines)
|
||||
{
|
||||
// Line not already processed?
|
||||
if (ld.LastProcessed != lastProcessed)//if(!visiblelines.Contains(ld))
|
||||
if (ld.LastProcessed != lastProcessed)
|
||||
{
|
||||
// Add line if not added yet
|
||||
ld.LastProcessed = lastProcessed;
|
||||
|
@ -560,6 +560,10 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// Things
|
||||
foreach(Thing t in block.Things)
|
||||
{
|
||||
if (t.LastProcessed == lastProcessed) continue;
|
||||
|
||||
t.LastProcessed = lastProcessed;
|
||||
|
||||
// Not filtered out?
|
||||
if(!General.Map.ThingsFilter.IsThingVisible(t)) continue;
|
||||
|
||||
|
@ -575,9 +579,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
allthings[t] = vt;
|
||||
}
|
||||
|
||||
if(vt != null && !visiblethings.ContainsKey(vt.Thing))
|
||||
if(vt != null)
|
||||
{
|
||||
visiblethings[vt.Thing] = vt;
|
||||
visiblethings.Add(vt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -630,6 +634,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// This finds and adds visible sectors
|
||||
private void ProcessSidedefCulling(Sidedef sd)
|
||||
{
|
||||
// Do nothing if we already added it.
|
||||
if (sd.LastProcessed == lastProcessed)
|
||||
return;
|
||||
|
||||
sd.LastProcessed = lastProcessed;
|
||||
|
||||
VisualSector vs;
|
||||
|
||||
// Find the visualsector and make it if needed
|
||||
|
@ -647,10 +657,10 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
if(vs != null)
|
||||
{
|
||||
// Add to visible sectors if not added yet
|
||||
if(!visiblesectors.ContainsKey(sd.Sector))
|
||||
if (sd.Sector.LastProcessed != lastProcessed)
|
||||
{
|
||||
visiblesectors.Add(sd.Sector, vs);
|
||||
sd.Sector.LastProcessed = lastProcessed;
|
||||
visiblesectors.Add(vs);
|
||||
visiblegeometry.AddRange(vs.FixedGeometry);
|
||||
}
|
||||
|
||||
|
@ -805,7 +815,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
|
||||
// Add all the visible things
|
||||
foreach(VisualThing vt in visiblethings.Values) pickables.Add(vt);
|
||||
foreach(VisualThing vt in visiblethings) pickables.Add(vt);
|
||||
|
||||
//mxd. And all visual vertices
|
||||
if(General.Map.UDMF && General.Settings.GZShowVisualVertices)
|
||||
|
|
|
@ -1340,7 +1340,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
renderer.DrawThingCages = ((BuilderPlug.Me.ShowVisualThings & 2) != 0);
|
||||
|
||||
// Render all visible things
|
||||
foreach(VisualThing t in visiblethings.Values)
|
||||
foreach(VisualThing t in visiblethings)
|
||||
renderer.AddThingGeometry(t);
|
||||
}
|
||||
|
||||
|
@ -1551,9 +1551,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(sectordata != null && sectordata.Count > 0) RebuildElementData();
|
||||
|
||||
//mxd. As well as geometry...
|
||||
foreach(KeyValuePair<Sector, VisualSector> group in visiblesectors)
|
||||
foreach(VisualSector sector in visiblesectors)
|
||||
{
|
||||
BaseVisualSector vs = (BaseVisualSector)group.Value;
|
||||
BaseVisualSector vs = (BaseVisualSector)sector;
|
||||
if(vs != null) vs.Rebuild();
|
||||
}
|
||||
|
||||
|
@ -1572,9 +1572,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(sectordata != null && sectordata.Count > 0) RebuildElementData();
|
||||
|
||||
//mxd. As well as geometry...
|
||||
foreach(KeyValuePair<Sector, VisualSector> group in visiblesectors)
|
||||
foreach(VisualSector sector in visiblesectors)
|
||||
{
|
||||
BaseVisualSector vs = (BaseVisualSector)group.Value;
|
||||
BaseVisualSector vs = (BaseVisualSector)sector;
|
||||
if(vs != null) vs.Rebuild();
|
||||
}
|
||||
|
||||
|
@ -3264,7 +3264,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach (IVisualEventReceiver i in objs)
|
||||
{
|
||||
if (i is BaseVisualThing)
|
||||
visiblethings.Remove(((BaseVisualThing)i).Thing); // [ZZ] if any
|
||||
visiblethings.Remove((BaseVisualThing)i); // [ZZ] if any
|
||||
i.OnDelete();
|
||||
}
|
||||
PostAction();
|
||||
|
@ -3305,7 +3305,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(IVisualEventReceiver i in objs)
|
||||
{
|
||||
BaseVisualThing thing = (BaseVisualThing)i;
|
||||
visiblethings.Remove(thing.Thing); // [ZZ] if any
|
||||
visiblethings.Remove(thing); // [ZZ] if any
|
||||
thing.Thing.Fields.BeforeFieldsChange();
|
||||
thing.Thing.Dispose();
|
||||
thing.Dispose();
|
||||
|
|
Loading…
Reference in a new issue