Refactor Polyobj_findSegs
This commit is contained in:
parent
8ae635c7ba
commit
02c347ada2
|
@ -356,12 +356,17 @@ static void Polyobj_findSegs(polyobj_t *po, seg_t *seg)
|
|||
// Find backfacings
|
||||
for (s = 0; s < numsegs; s++)
|
||||
{
|
||||
size_t r;
|
||||
|
||||
if (segs[s].glseg)
|
||||
continue;
|
||||
if (segs[s].linedef == seg->linedef
|
||||
&& segs[s].side == 1)
|
||||
{
|
||||
size_t r;
|
||||
|
||||
if (segs[s].linedef != seg->linedef)
|
||||
continue;
|
||||
|
||||
if (segs[s].side != 1)
|
||||
continue;
|
||||
|
||||
for (r = 0; r < po->segCount; r++)
|
||||
{
|
||||
if (po->segs[r] == &segs[s])
|
||||
|
@ -376,7 +381,6 @@ static void Polyobj_findSegs(polyobj_t *po, seg_t *seg)
|
|||
Polyobj_addSeg(po, &segs[s]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// on first seg, save the initial vertex
|
||||
startx = seg->v1->x;
|
||||
|
@ -394,14 +398,18 @@ newseg:
|
|||
// seg's ending vertex.
|
||||
for (i = 0; i < numsegs; ++i)
|
||||
{
|
||||
size_t q;
|
||||
|
||||
if (segs[i].glseg)
|
||||
continue;
|
||||
if (segs[i].side != 0) // needs to be frontfacing
|
||||
continue;
|
||||
if (segs[i].v1->x == seg->v2->x && segs[i].v1->y == seg->v2->y)
|
||||
{
|
||||
if (segs[i].v1->x != seg->v2->x)
|
||||
continue;
|
||||
if (segs[i].v1->y != seg->v2->y)
|
||||
continue;
|
||||
|
||||
// Make sure you didn't already add this seg...
|
||||
size_t q;
|
||||
for (q = 0; q < po->segCount; q++)
|
||||
{
|
||||
if (po->segs[q] == &segs[i])
|
||||
|
@ -420,14 +428,16 @@ newseg:
|
|||
// Find backfacings
|
||||
for (q = 0; q < numsegs; q++)
|
||||
{
|
||||
size_t r;
|
||||
|
||||
if (segs[q].glseg)
|
||||
continue;
|
||||
if (segs[q].linedef != segs[i].linedef)
|
||||
continue;
|
||||
if (segs[q].side != 1)
|
||||
continue;
|
||||
|
||||
if (segs[q].linedef == segs[i].linedef
|
||||
&& segs[q].side == 1)
|
||||
{
|
||||
size_t r;
|
||||
for (r=0; r < po->segCount; r++)
|
||||
for (r = 0; r < po->segCount; r++)
|
||||
{
|
||||
if (po->segs[r] == &segs[q])
|
||||
break;
|
||||
|
@ -440,11 +450,9 @@ newseg:
|
|||
Polyobj_addSeg(po, &segs[q]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
goto newseg;
|
||||
}
|
||||
}
|
||||
|
||||
// error: if we reach here, the seg search never found another seg to
|
||||
// continue the loop, and thus the polyobject is open. This isn't allowed.
|
||||
|
|
Loading…
Reference in New Issue