- Fix crash when switching levels

This commit is contained in:
Magnus Norddahl 2017-09-10 17:11:17 +02:00
parent 4d671fb618
commit 0924cc3f0f
2 changed files with 19 additions and 6 deletions

View file

@ -33,6 +33,16 @@ void PolyCull::CullScene(const TriMatrix &worldToClip, const PolyClipPlane &port
ClearSolidSegments();
MarkViewFrustum();
if (level.LevelName != lastLevelName) // Is this the best way to detect a level change?
{
lastLevelName = level.LevelName;
SubsectorDepths.clear();
SubsectorDepths.resize(level.subsectors.Size(), 0xffffffff);
SectorSeen.clear();
SectorSeen.resize(level.sectors.Size());
}
else
{
for (const auto &sub : PvsSectors)
SubsectorDepths[sub->Index()] = 0xffffffff;
SubsectorDepths.resize(level.subsectors.Size(), 0xffffffff);
@ -40,6 +50,7 @@ void PolyCull::CullScene(const TriMatrix &worldToClip, const PolyClipPlane &port
for (const auto &sector : SeenSectors)
SectorSeen[sector->Index()] = false;
SectorSeen.resize(level.sectors.Size());
}
PvsSectors.clear();
SeenSectors.clear();

View file

@ -70,6 +70,8 @@ private:
void MarkSegmentCulled(angle_t angle1, angle_t angle2);
FString lastLevelName;
std::vector<SolidSegment> SolidSegments;
std::vector<SolidSegment> TempInvertSolidSegments;
const int SolidCullScale = 3000;