Visual Mode: Store slope vertices in a separate list, to prevent iterating over all things for every single vertex slope linedef found.

This commit is contained in:
sphere 2021-10-17 15:14:34 +02:00
parent 34831d6042
commit 8ef05744f9

View file

@ -818,6 +818,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
Dictionary<int, List<Sector>> sectortags = new Dictionary<int, List<Sector>>();
List<Thing> slopethings = new List<Thing>();
sectordata = new Dictionary<Sector, SectorData>(General.Map.Map.Sectors.Count);
thingdata = new Dictionary<Thing, ThingData>(General.Map.Map.Things.Count);
@ -847,6 +848,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
if (!General.Settings.GZDoomRenderingEffects) return; //mxd
if (General.Map.SRB2)
{
// Find all slope vertex things and store them
foreach (Thing t in General.Map.Map.Things)
{
if (t.IsSlopeVertex) slopethings.Add(t);
}
}
foreach (Sector s in General.Map.Map.Sectors)
{
// Find all sector whose tag is not 0 and hash them so that we can find them quickly
@ -1053,15 +1063,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sidedef side = (l.Args[0] == 0 || l.Args[0] == 1) ? l.Front : l.Back;
Sector s = side.Sector;
//If NOKNUCKLES is set, use tag, X offset and Y offset to search for slope vertices.
//If Effect 6 is set, use tag, X offset and Y offset to search for slope vertices.
if (l.IsFlagSet("8192"))
{
bool foundtag = false;
bool foundxoffset = false;
bool foundyoffset = false;
foreach (Thing t in General.Map.Map.Things)
{
if (t.IsSlopeVertex)
foreach (Thing t in slopethings)
{
if (!foundtag && (int)t.AngleDoom == l.Tag)
{
@ -1079,15 +1087,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
foundyoffset = true;
}
}
}
}
//Otherwise, just use tag.
else
{
foreach (Thing t in General.Map.Map.Things)
foreach (Thing t in slopethings)
{
if (t.IsSlopeVertex && (int)t.AngleDoom == l.Tag) slopevertices.Add(t);
if ((int)t.AngleDoom == l.Tag) slopevertices.Add(t);
}
}
if (slopevertices.Count >= 3)