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>>(); 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); sectordata = new Dictionary<Sector, SectorData>(General.Map.Map.Sectors.Count);
thingdata = new Dictionary<Thing, ThingData>(General.Map.Map.Things.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.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) 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 // Find all sector whose tag is not 0 and hash them so that we can find them quickly
@ -1053,31 +1063,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sidedef side = (l.Args[0] == 0 || l.Args[0] == 1) ? l.Front : l.Back; Sidedef side = (l.Args[0] == 0 || l.Args[0] == 1) ? l.Front : l.Back;
Sector s = side.Sector; 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")) if (l.IsFlagSet("8192"))
{ {
bool foundtag = false; bool foundtag = false;
bool foundxoffset = false; bool foundxoffset = false;
bool foundyoffset = false; bool foundyoffset = false;
foreach (Thing t in General.Map.Map.Things) foreach (Thing t in slopethings)
{ {
if (t.IsSlopeVertex) if (!foundtag && (int)t.AngleDoom == l.Tag)
{ {
if (!foundtag && (int)t.AngleDoom == l.Tag) slopevertices.Add(t);
{ foundtag = true;
slopevertices.Add(t); }
foundtag = true; if (!foundxoffset && (int)t.AngleDoom == side.OffsetX)
} {
if (!foundxoffset && (int)t.AngleDoom == side.OffsetX) slopevertices.Add(t);
{ foundxoffset = true;
slopevertices.Add(t); }
foundxoffset = true; if (!foundyoffset && (int)t.AngleDoom == side.OffsetY)
} {
if (!foundyoffset && (int)t.AngleDoom == side.OffsetY) slopevertices.Add(t);
{ foundyoffset = true;
slopevertices.Add(t);
foundyoffset = true;
}
} }
} }
@ -1085,9 +1092,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
//Otherwise, just use tag. //Otherwise, just use tag.
else 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) if (slopevertices.Count >= 3)