mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Remove more dictionaries from the render loop
This commit is contained in:
parent
026324779e
commit
1435208163
5 changed files with 56 additions and 35 deletions
|
@ -85,9 +85,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private ReadOnlyCollection<LabelPositionInfo> labels;
|
||||
private readonly SurfaceEntryCollection surfaceentries;
|
||||
|
||||
//mxd. Rendering
|
||||
private Color4 fogcolor;
|
||||
private SectorFogMode fogmode;
|
||||
//mxd. Rendering
|
||||
private Color4 fogcolor;
|
||||
private SectorFogMode fogmode;
|
||||
private int lastProcessed;
|
||||
|
||||
//mxd. Slopes
|
||||
private Vector3D floorslope;
|
||||
|
@ -134,6 +135,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
|
||||
|
||||
|
|
|
@ -57,6 +57,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Clone
|
||||
private int serializedindex;
|
||||
|
||||
// Rendering
|
||||
private int lastProcessed;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -91,9 +91,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private bool fixedsize;
|
||||
private bool directional; //mxd. If true, we need to render an arrow
|
||||
|
||||
#endregion
|
||||
// Rendering
|
||||
private int lastProcessed;
|
||||
|
||||
#region ================== Properties
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public MapSet Map { get { return map; } }
|
||||
public int FullType { get { return type; } set { BeforePropsChange(); type = value; } } //mxd
|
||||
|
@ -132,6 +135,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
public bool IsReverse { get { return General.Map.SRB2 && !Unflippable && IsFlagSet("2"); } }
|
||||
public bool Unflippable { get { return General.Map.Data.GetThingInfo(Type).IsUnflippable; } }
|
||||
internal int LastProcessed { get { return lastProcessed; } set { lastProcessed = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
|
|
@ -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
|
||||
|
@ -102,12 +102,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
this.renderer = General.Map.Renderer3D;
|
||||
this.blockmap = new VisualBlockMap();
|
||||
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.allthings = new Dictionary<Thing, VisualThing>(General.Map.Map.Things.Count);
|
||||
this.visibleblocks = new List<VisualBlockEntry>();
|
||||
this.visiblesectors = new List<VisualSector>(50);
|
||||
this.visiblegeometry = new List<VisualGeometry>(200);
|
||||
this.visiblethings = new Dictionary<Thing, VisualThing>(100);
|
||||
this.processgeometry = true;
|
||||
this.visiblethings = new List<VisualThing>(100);
|
||||
this.processgeometry = true;
|
||||
this.processthings = true;
|
||||
this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd
|
||||
|
||||
|
@ -525,9 +525,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);
|
||||
|
@ -541,7 +541,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;
|
||||
|
@ -567,6 +567,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;
|
||||
|
||||
|
@ -582,9 +586,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -637,7 +641,13 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// This finds and adds visible sectors
|
||||
private void ProcessSidedefCulling(Sidedef sd)
|
||||
{
|
||||
VisualSector vs;
|
||||
// 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
|
||||
if(allsectors.ContainsKey(sd.Sector))
|
||||
|
@ -654,12 +664,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
if(vs != null)
|
||||
{
|
||||
// Add to visible sectors if not added yet
|
||||
if(!visiblesectors.ContainsKey(sd.Sector))
|
||||
{
|
||||
visiblesectors.Add(sd.Sector, vs);
|
||||
visiblegeometry.AddRange(vs.FixedGeometry);
|
||||
}
|
||||
if (sd.Sector.LastProcessed != lastProcessed)
|
||||
{
|
||||
sd.Sector.LastProcessed = lastProcessed;
|
||||
visiblesectors.Add(vs);
|
||||
visiblegeometry.AddRange(vs.FixedGeometry);
|
||||
}
|
||||
|
||||
// Add sidedef geometry
|
||||
visiblegeometry.AddRange(vs.GetSidedefGeometry(sd));
|
||||
|
@ -810,9 +820,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add all the visible things
|
||||
foreach (VisualThing vt in visiblethings.Values) pickables.Add(vt);
|
||||
|
||||
// Add all the visible things
|
||||
foreach(VisualThing vt in visiblethings) pickables.Add(vt);
|
||||
|
||||
//mxd. And all visual vertices
|
||||
if (General.Map.UDMF && General.Settings.GZShowVisualVertices)
|
||||
|
|
|
@ -1512,7 +1512,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);
|
||||
}
|
||||
|
||||
|
@ -1723,9 +1723,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();
|
||||
}
|
||||
|
||||
|
@ -1744,9 +1744,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();
|
||||
}
|
||||
|
||||
|
@ -3398,7 +3398,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();
|
||||
|
@ -3439,7 +3439,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