- fixed renderer to avoid bunches of walls that wrap around behind the camera's back.

This commit is contained in:
Christoph Oelckers 2021-04-07 16:09:25 +02:00
parent 3a34043267
commit caa8efd3d5
2 changed files with 16 additions and 11 deletions

View File

@ -94,15 +94,16 @@ void BunchDrawer::StartScene()
//
//==========================================================================
void BunchDrawer::StartBunch(int sectnum, int linenum, binangle startan, binangle endan, bool portal)
bool BunchDrawer::StartBunch(int sectnum, int linenum, binangle startan, binangle endan, bool portal)
{
FBunch* bunch = &Bunches[LastBunch = Bunches.Reserve(1)];
bunch->sectnum = sectnum;
bunch->startline = bunch->endline = linenum;
bunch->startangle = startan;
bunch->endangle = endan;
bunch->startangle = (startan.asbam() - ang1.asbam()) > ANGLE_180? ang1 :startan;
bunch->endangle = (endan.asbam() - ang2.asbam()) < ANGLE_180 ? ang2 : endan;
bunch->portal = portal;
return bunch->endangle != ang2;
}
//==========================================================================
@ -111,10 +112,11 @@ void BunchDrawer::StartBunch(int sectnum, int linenum, binangle startan, binangl
//
//==========================================================================
void BunchDrawer::AddLineToBunch(int line, binangle newan)
bool BunchDrawer::AddLineToBunch(int line, binangle newan)
{
Bunches[LastBunch].endline++;
Bunches[LastBunch].endangle = newan;
Bunches[LastBunch].endangle = (newan.asbam() - ang2.asbam()) < ANGLE_180 ? ang2 : newan;
return Bunches[LastBunch].endangle != ang2;
}
//==========================================================================
@ -421,6 +423,7 @@ int BunchDrawer::FindClosestBunch()
}
}
//Printf("picked bunch starting at %d\n", Bunches[closest].startline);
return closest;
}
@ -497,12 +500,13 @@ void BunchDrawer::ProcessSector(int sectnum, bool portal)
else if (!inbunch)
{
startangle = walang1;
StartBunch(sectnum, sect->wallptr + i, walang1, walang2, portal);
inbunch = true;
//Printf("Starting bunch:\n\tWall %d\n", sect->wallptr + i);
inbunch = StartBunch(sectnum, sect->wallptr + i, walang1, walang2, portal);
}
else
{
AddLineToBunch(sect->wallptr + i, walang2);
//Printf("\tWall %d\n", sect->wallptr + i);
inbunch = AddLineToBunch(sect->wallptr + i, walang2);
}
if (thiswall->point2 != sect->wallptr + i + 1) inbunch = false;
}
@ -516,6 +520,7 @@ void BunchDrawer::ProcessSector(int sectnum, bool portal)
void BunchDrawer::RenderScene(const int* viewsectors, unsigned sectcount, bool portal)
{
//Printf("----------------------------------------- \n");
auto process = [&]()
{
for (unsigned i = 0; i < sectcount; i++)

View File

@ -12,7 +12,7 @@ struct FBunch
int startline;
int endline;
bool portal;
binangle startangle; // in pseudo angles for the clipper
binangle startangle;
binangle endangle;
};
@ -41,8 +41,8 @@ private:
};
void StartScene();
void StartBunch(int sectnum, int linenum, binangle startan, binangle endan, bool portal);
void AddLineToBunch(int line, binangle newan);
bool StartBunch(int sectnum, int linenum, binangle startan, binangle endan, bool portal);
bool AddLineToBunch(int line, binangle newan);
void DeleteBunch(int index);
bool CheckClip(walltype* wal);
int ClipLine(int line, bool portal);