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
|
//mxd. Rendering
|
||||||
private Color4 fogcolor;
|
private Color4 fogcolor;
|
||||||
private SectorFogMode fogmode;
|
private SectorFogMode fogmode;
|
||||||
|
private int lastProcessed;
|
||||||
|
|
||||||
//mxd. Slopes
|
//mxd. Slopes
|
||||||
private Vector3D floorslope;
|
private Vector3D floorslope;
|
||||||
|
@ -142,6 +143,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
public float FloorSlopeOffset { get { return flooroffset; } set { BeforePropsChange(); flooroffset = value; updateneeded = true; } }
|
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 Vector3D CeilSlope { get { return ceilslope; } set { BeforePropsChange(); ceilslope = value; updateneeded = true; } }
|
||||||
public float CeilSlopeOffset { get { return ceiloffset; } set { BeforePropsChange(); ceiloffset = 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
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,9 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
// Clone
|
// Clone
|
||||||
private int serializedindex;
|
private int serializedindex;
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
private int lastProcessed;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -78,6 +81,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
public long LongMiddleTexture { get { return longtexnamemid; } }
|
public long LongMiddleTexture { get { return longtexnamemid; } }
|
||||||
public long LongLowTexture { get { return longtexnamelow; } }
|
public long LongLowTexture { get { return longtexnamelow; } }
|
||||||
internal int SerializedIndex { get { return serializedindex; } set { serializedindex = value; } }
|
internal int SerializedIndex { get { return serializedindex; } set { serializedindex = value; } }
|
||||||
|
internal int LastProcessed { get { return lastProcessed; } set { lastProcessed = value; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -86,11 +86,14 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
private bool fixedsize;
|
private bool fixedsize;
|
||||||
private bool directional; //mxd. If true, we need to render an arrow
|
private bool directional; //mxd. If true, we need to render an arrow
|
||||||
|
|
||||||
#endregion
|
// Rendering
|
||||||
|
private int lastProcessed;
|
||||||
|
|
||||||
#region ================== Properties
|
#endregion
|
||||||
|
|
||||||
public MapSet Map { get { return map; } }
|
#region ================== Properties
|
||||||
|
|
||||||
|
public MapSet Map { get { return map; } }
|
||||||
public int Type { get { return type; } set { BeforePropsChange(); type = value; } } //mxd
|
public int Type { get { return type; } set { BeforePropsChange(); type = value; } } //mxd
|
||||||
public GZGeneral.LightData DynamicLightType { get { return dynamiclighttype; } internal set { BeforePropsChange(); dynamiclighttype = value; } }
|
public GZGeneral.LightData DynamicLightType { get { return dynamiclighttype; } internal set { BeforePropsChange(); dynamiclighttype = value; } }
|
||||||
public Vector3D Position { get { return pos; } }
|
public Vector3D Position { get { return pos; } }
|
||||||
|
@ -116,13 +119,14 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
public ThingRenderMode RenderMode { get { return rendermode; } } //mxd
|
public ThingRenderMode RenderMode { get { return rendermode; } } //mxd
|
||||||
public bool IsDirectional { get { return directional; } } //mxd
|
public bool IsDirectional { get { return directional; } } //mxd
|
||||||
public bool Highlighted { get { return highlighted; } set { highlighted = value; } } //mxd
|
public bool Highlighted { get { return highlighted; } set { highlighted = value; } } //mxd
|
||||||
|
internal int LastProcessed { get { return lastProcessed; } set { lastProcessed = value; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Constructor / Disposer
|
#region ================== Constructor / Disposer
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
internal Thing(MapSet map, int listindex)
|
internal Thing(MapSet map, int listindex)
|
||||||
{
|
{
|
||||||
// Initialize
|
// Initialize
|
||||||
this.elementtype = MapElementType.THING; //mxd
|
this.elementtype = MapElementType.THING; //mxd
|
||||||
|
|
|
@ -73,8 +73,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
protected Dictionary<Thing, VisualThing> allthings;
|
protected Dictionary<Thing, VisualThing> allthings;
|
||||||
protected Dictionary<Sector, VisualSector> allsectors;
|
protected Dictionary<Sector, VisualSector> allsectors;
|
||||||
protected List<VisualBlockEntry> visibleblocks;
|
protected List<VisualBlockEntry> visibleblocks;
|
||||||
protected Dictionary<Thing, VisualThing> visiblethings;
|
protected List<VisualThing> visiblethings;
|
||||||
protected Dictionary<Sector, VisualSector> visiblesectors;
|
protected List<VisualSector> visiblesectors;
|
||||||
protected List<VisualGeometry> visiblegeometry;
|
protected List<VisualGeometry> visiblegeometry;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -104,9 +104,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
this.allsectors = new Dictionary<Sector, VisualSector>(General.Map.Map.Sectors.Count);
|
this.allsectors = new Dictionary<Sector, VisualSector>(General.Map.Map.Sectors.Count);
|
||||||
this.allthings = new Dictionary<Thing, VisualThing>(General.Map.Map.Things.Count);
|
this.allthings = new Dictionary<Thing, VisualThing>(General.Map.Map.Things.Count);
|
||||||
this.visibleblocks = new List<VisualBlockEntry>();
|
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.visiblegeometry = new List<VisualGeometry>(200);
|
||||||
this.visiblethings = new Dictionary<Thing, VisualThing>(100);
|
this.visiblethings = new List<VisualThing>(100);
|
||||||
this.processgeometry = true;
|
this.processgeometry = true;
|
||||||
this.processthings = true;
|
this.processthings = true;
|
||||||
this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd
|
this.vertices = new Dictionary<Vertex, VisualVertexPair>(); //mxd
|
||||||
|
@ -518,9 +518,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
Vector2D campos2d = General.Map.VisualCamera.Position;
|
Vector2D campos2d = General.Map.VisualCamera.Position;
|
||||||
|
|
||||||
// Make collections
|
// Make collections
|
||||||
visiblesectors = new Dictionary<Sector, VisualSector>(visiblesectors.Count);
|
visiblesectors = new List<VisualSector>(visiblesectors.Count * 2);
|
||||||
visiblegeometry = new List<VisualGeometry>(visiblegeometry.Capacity);
|
visiblegeometry = new List<VisualGeometry>(visiblegeometry.Count * 2);
|
||||||
visiblethings = new Dictionary<Thing, VisualThing>(visiblethings.Count);
|
visiblethings = new List<VisualThing>(visiblethings.Count * 2);
|
||||||
|
|
||||||
// Get the blocks within view range
|
// Get the blocks within view range
|
||||||
visibleblocks = blockmap.GetFrustumRange(renderer.Frustum2D);
|
visibleblocks = blockmap.GetFrustumRange(renderer.Frustum2D);
|
||||||
|
@ -534,7 +534,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
foreach(Linedef ld in block.Lines)
|
foreach(Linedef ld in block.Lines)
|
||||||
{
|
{
|
||||||
// Line not already processed?
|
// Line not already processed?
|
||||||
if (ld.LastProcessed != lastProcessed)//if(!visiblelines.Contains(ld))
|
if (ld.LastProcessed != lastProcessed)
|
||||||
{
|
{
|
||||||
// Add line if not added yet
|
// Add line if not added yet
|
||||||
ld.LastProcessed = lastProcessed;
|
ld.LastProcessed = lastProcessed;
|
||||||
|
@ -560,6 +560,10 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
// Things
|
// Things
|
||||||
foreach(Thing t in block.Things)
|
foreach(Thing t in block.Things)
|
||||||
{
|
{
|
||||||
|
if (t.LastProcessed == lastProcessed) continue;
|
||||||
|
|
||||||
|
t.LastProcessed = lastProcessed;
|
||||||
|
|
||||||
// Not filtered out?
|
// Not filtered out?
|
||||||
if(!General.Map.ThingsFilter.IsThingVisible(t)) continue;
|
if(!General.Map.ThingsFilter.IsThingVisible(t)) continue;
|
||||||
|
|
||||||
|
@ -575,9 +579,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
allthings[t] = vt;
|
allthings[t] = vt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vt != null && !visiblethings.ContainsKey(vt.Thing))
|
if(vt != null)
|
||||||
{
|
{
|
||||||
visiblethings[vt.Thing] = vt;
|
visiblethings.Add(vt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -630,7 +634,13 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
// This finds and adds visible sectors
|
// This finds and adds visible sectors
|
||||||
private void ProcessSidedefCulling(Sidedef sd)
|
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
|
// Find the visualsector and make it if needed
|
||||||
if(allsectors.ContainsKey(sd.Sector))
|
if(allsectors.ContainsKey(sd.Sector))
|
||||||
|
@ -647,12 +657,12 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
|
|
||||||
if(vs != null)
|
if(vs != null)
|
||||||
{
|
{
|
||||||
// Add to visible sectors if not added yet
|
if (sd.Sector.LastProcessed != lastProcessed)
|
||||||
if(!visiblesectors.ContainsKey(sd.Sector))
|
{
|
||||||
{
|
sd.Sector.LastProcessed = lastProcessed;
|
||||||
visiblesectors.Add(sd.Sector, vs);
|
visiblesectors.Add(vs);
|
||||||
visiblegeometry.AddRange(vs.FixedGeometry);
|
visiblegeometry.AddRange(vs.FixedGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add sidedef geometry
|
// Add sidedef geometry
|
||||||
visiblegeometry.AddRange(vs.GetSidedefGeometry(sd));
|
visiblegeometry.AddRange(vs.GetSidedefGeometry(sd));
|
||||||
|
@ -805,7 +815,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all the visible things
|
// 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
|
//mxd. And all visual vertices
|
||||||
if(General.Map.UDMF && General.Settings.GZShowVisualVertices)
|
if(General.Map.UDMF && General.Settings.GZShowVisualVertices)
|
||||||
|
|
|
@ -1340,7 +1340,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
renderer.DrawThingCages = ((BuilderPlug.Me.ShowVisualThings & 2) != 0);
|
renderer.DrawThingCages = ((BuilderPlug.Me.ShowVisualThings & 2) != 0);
|
||||||
|
|
||||||
// Render all visible things
|
// Render all visible things
|
||||||
foreach(VisualThing t in visiblethings.Values)
|
foreach(VisualThing t in visiblethings)
|
||||||
renderer.AddThingGeometry(t);
|
renderer.AddThingGeometry(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1551,9 +1551,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
if(sectordata != null && sectordata.Count > 0) RebuildElementData();
|
if(sectordata != null && sectordata.Count > 0) RebuildElementData();
|
||||||
|
|
||||||
//mxd. As well as geometry...
|
//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();
|
if(vs != null) vs.Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1572,9 +1572,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
if(sectordata != null && sectordata.Count > 0) RebuildElementData();
|
if(sectordata != null && sectordata.Count > 0) RebuildElementData();
|
||||||
|
|
||||||
//mxd. As well as geometry...
|
//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();
|
if(vs != null) vs.Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3264,7 +3264,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
foreach (IVisualEventReceiver i in objs)
|
foreach (IVisualEventReceiver i in objs)
|
||||||
{
|
{
|
||||||
if (i is BaseVisualThing)
|
if (i is BaseVisualThing)
|
||||||
visiblethings.Remove(((BaseVisualThing)i).Thing); // [ZZ] if any
|
visiblethings.Remove((BaseVisualThing)i); // [ZZ] if any
|
||||||
i.OnDelete();
|
i.OnDelete();
|
||||||
}
|
}
|
||||||
PostAction();
|
PostAction();
|
||||||
|
@ -3305,7 +3305,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
||||||
foreach(IVisualEventReceiver i in objs)
|
foreach(IVisualEventReceiver i in objs)
|
||||||
{
|
{
|
||||||
BaseVisualThing thing = (BaseVisualThing)i;
|
BaseVisualThing thing = (BaseVisualThing)i;
|
||||||
visiblethings.Remove(thing.Thing); // [ZZ] if any
|
visiblethings.Remove(thing); // [ZZ] if any
|
||||||
thing.Thing.Fields.BeforeFieldsChange();
|
thing.Thing.Fields.BeforeFieldsChange();
|
||||||
thing.Thing.Dispose();
|
thing.Thing.Dispose();
|
||||||
thing.Dispose();
|
thing.Dispose();
|
||||||
|
|
Loading…
Reference in a new issue