- fixed sector mesh generator to allow sectors with non-continuous wall loops.

Blood has a few such sectors.
This commit is contained in:
Christoph Oelckers 2021-03-31 21:26:57 +02:00
parent 4cc0afe587
commit 3c4429f2a8

View file

@ -224,26 +224,39 @@ void SectorGeometry::MakeVertices(unsigned int secnum, int plane)
polygon.resize(1); polygon.resize(1);
curPoly = &polygon.back(); curPoly = &polygon.back();
FixedBitArray<MAXWALLSB> done;
int fz = sec->floorz, cz = sec->ceilingz; int fz = sec->floorz, cz = sec->ceilingz;
sec->floorz = sec->ceilingz = 0; sec->floorz = sec->ceilingz = 0;
for (int i = 0; i < numvertices; i++) int vertstoadd = numvertices;
{
auto wal = &wall[sec->wallptr + i];
float X = WallStartX(wal); done.Zero();
float Y = WallStartY(wal); while (vertstoadd > 0)
if (fabs(X) > 32768. || fabs(Y) > 32768.) {
{ int start = 0;
// If we get here there's some fuckery going around with the coordinates. Let's better abort and wait for things to realign. while (done[start] && start < numvertices) start++;
return; int s = start;
} if (start < numvertices)
curPoly->push_back(std::make_pair(X, Y));
if (wal->point2 != sec->wallptr+i+1 && i < numvertices - 1)
{ {
while (!done[start])
{
auto wallp = &wall[sec->wallptr + start];
float X = WallStartX(wallp);
float Y = WallStartY(wallp);
if (fabs(X) > 32768. || fabs(Y) > 32768.)
{
// If we get here there's some fuckery going around with the coordinates. Let's better abort and wait for things to realign.
return;
}
curPoly->push_back(std::make_pair(X, Y));
done.Set(start);
vertstoadd--;
start = wallp->point2 - sec->wallptr;
}
polygon.resize(polygon.size() + 1); polygon.resize(polygon.size() + 1);
curPoly = &polygon.back(); curPoly = &polygon.back();
assert(start == s);
} }
} }
// Now make sure that the outer boundary is the first polygon by picking a point that's as much to the outside as possible. // Now make sure that the outer boundary is the first polygon by picking a point that's as much to the outside as possible.