mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 23:32:04 +00:00
- fixed a crash when initializing the GL portal data for an incomplete or inactive portal. Also did a bit of cleanup on this code, the 'delta' member was never used.
This commit is contained in:
parent
a2f56b6ef5
commit
c5db5dff99
3 changed files with 33 additions and 39 deletions
|
@ -56,9 +56,8 @@ struct FPortal
|
||||||
|
|
||||||
struct FGLLinePortal
|
struct FGLLinePortal
|
||||||
{
|
{
|
||||||
// defines the complete span of this portal
|
// defines the complete span of this portal, if this is of type PORTT_LINKED.
|
||||||
vertex_t *v1, *v2; // vertices, from v1 to v2
|
vertex_t *v1 = nullptr, *v2 = nullptr; // vertices, from v1 to v2
|
||||||
DVector2 delta; // precalculated v2 - v1 for side checking
|
|
||||||
TArray<FLinePortal *> lines;
|
TArray<FLinePortal *> lines;
|
||||||
int validcount = 0;
|
int validcount = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -443,54 +443,49 @@ void gl_InitPortals()
|
||||||
tempindex[i] = glLinePortals.Size();
|
tempindex[i] = glLinePortals.Size();
|
||||||
line_t *pSrcLine = linePortals[i].mOrigin;
|
line_t *pSrcLine = linePortals[i].mOrigin;
|
||||||
line_t *pLine = linePortals[i].mDestination;
|
line_t *pLine = linePortals[i].mDestination;
|
||||||
FGLLinePortal glport;
|
FGLLinePortal &glport = glLinePortals[glLinePortals.Reserve(1)];
|
||||||
|
|
||||||
glport.v1 = pLine->v1;
|
|
||||||
glport.v2 = pLine->v2;
|
|
||||||
glport.delta = { 0, 0 };
|
|
||||||
glport.lines.Push(&linePortals[i]);
|
glport.lines.Push(&linePortals[i]);
|
||||||
glLinePortals.Push(glport);
|
|
||||||
|
|
||||||
// We cannot do this grouping for non-linked portals because they can be changed at run time.
|
// We cannot do this grouping for non-linked portals because they can be changed at run time.
|
||||||
if (linePortals[i].mType == PORTT_LINKED)
|
if (linePortals[i].mType == PORTT_LINKED && pLine != nullptr)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
// now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match
|
glport.v1 = pLine->v1;
|
||||||
gotsome = false;
|
glport.v2 = pLine->v2;
|
||||||
for (unsigned j = 0; j < linePortals.Size(); j++)
|
do
|
||||||
{
|
{
|
||||||
if (tempindex[j] == -1)
|
// now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match
|
||||||
|
gotsome = false;
|
||||||
|
for (unsigned j = 0; j < linePortals.Size(); j++)
|
||||||
{
|
{
|
||||||
line_t *pSrcLine2 = linePortals[j].mOrigin;
|
if (tempindex[j] == -1)
|
||||||
line_t *pLine2 = linePortals[j].mDestination;
|
|
||||||
// angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical portals aren't found here.)
|
|
||||||
unsigned srcang = pSrcLine->Delta().Angle().BAMs();
|
|
||||||
unsigned dstang = pLine->Delta().Angle().BAMs();
|
|
||||||
if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) ||
|
|
||||||
(pSrcLine->v1 == pSrcLine2->v2 && pLine->v2 == pLine2->v1))
|
|
||||||
{
|
{
|
||||||
// The line connects, now check the translation
|
line_t *pSrcLine2 = linePortals[j].mOrigin;
|
||||||
unsigned srcang2 = pSrcLine2->Delta().Angle().BAMs();
|
line_t *pLine2 = linePortals[j].mDestination;
|
||||||
unsigned dstang2 = pLine2->Delta().Angle().BAMs();
|
// angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical portals aren't found here.)
|
||||||
if (srcang == srcang2 && dstang == dstang2)
|
unsigned srcang = pSrcLine->Delta().Angle().BAMs();
|
||||||
|
unsigned dstang = pLine->Delta().Angle().BAMs();
|
||||||
|
if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) ||
|
||||||
|
(pSrcLine->v1 == pSrcLine2->v2 && pLine->v2 == pLine2->v1))
|
||||||
{
|
{
|
||||||
// The lines connect and both source and destination are colinear, so this is a match
|
// The line connects, now check the translation
|
||||||
gotsome = true;
|
unsigned srcang2 = pSrcLine2->Delta().Angle().BAMs();
|
||||||
tempindex[j] = tempindex[i];
|
unsigned dstang2 = pLine2->Delta().Angle().BAMs();
|
||||||
if (pLine->v1 == pLine2->v2) glLinePortals[tempindex[i]].v1 = pLine2->v1;
|
if (srcang == srcang2 && dstang == dstang2)
|
||||||
else glLinePortals[tempindex[i]].v2 = pLine2->v2;
|
{
|
||||||
glLinePortals[tempindex[i]].lines.Push(&linePortals[j]);
|
// The lines connect and both source and destination are colinear, so this is a match
|
||||||
|
gotsome = true;
|
||||||
|
tempindex[j] = tempindex[i];
|
||||||
|
if (pLine->v1 == pLine2->v2) glport.v1 = pLine2->v1;
|
||||||
|
else glport.v2 = pLine2->v2;
|
||||||
|
glport.lines.Push(&linePortals[j]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} while (gotsome);
|
||||||
} while (gotsome);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto glport : glLinePortals)
|
|
||||||
{
|
|
||||||
glport.delta = glport.v2->fPos() - glport.v1->fPos();
|
|
||||||
}
|
|
||||||
linePortalToGL.Resize(linePortals.Size());
|
linePortalToGL.Resize(linePortals.Size());
|
||||||
for (unsigned i = 0; i < linePortals.Size(); i++)
|
for (unsigned i = 0; i < linePortals.Size(); i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -195,7 +195,7 @@ struct GLLinePortal : public GLPortal
|
||||||
|
|
||||||
GLLinePortal(FGLLinePortal *line)
|
GLLinePortal(FGLLinePortal *line)
|
||||||
{
|
{
|
||||||
if (line->lines[0]->mType != PORTT_LINKED)
|
if (line->lines[0]->mType != PORTT_LINKED || line->v1 == nullptr)
|
||||||
{
|
{
|
||||||
// For non-linked portals we must check the actual linedef.
|
// For non-linked portals we must check the actual linedef.
|
||||||
line_t *lline = line->lines[0]->mDestination;
|
line_t *lline = line->lines[0]->mDestination;
|
||||||
|
|
Loading…
Reference in a new issue