mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Refactor Polyobj_findSegs
This commit is contained in:
parent
8ae635c7ba
commit
02c347ada2
1 changed files with 67 additions and 59 deletions
|
@ -356,12 +356,17 @@ static void Polyobj_findSegs(polyobj_t *po, seg_t *seg)
|
||||||
// Find backfacings
|
// Find backfacings
|
||||||
for (s = 0; s < numsegs; s++)
|
for (s = 0; s < numsegs; s++)
|
||||||
{
|
{
|
||||||
|
size_t r;
|
||||||
|
|
||||||
if (segs[s].glseg)
|
if (segs[s].glseg)
|
||||||
continue;
|
continue;
|
||||||
if (segs[s].linedef == seg->linedef
|
|
||||||
&& segs[s].side == 1)
|
if (segs[s].linedef != seg->linedef)
|
||||||
{
|
continue;
|
||||||
size_t r;
|
|
||||||
|
if (segs[s].side != 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (r = 0; r < po->segCount; r++)
|
for (r = 0; r < po->segCount; r++)
|
||||||
{
|
{
|
||||||
if (po->segs[r] == &segs[s])
|
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]);
|
Polyobj_addSeg(po, &segs[s]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// on first seg, save the initial vertex
|
// on first seg, save the initial vertex
|
||||||
startx = seg->v1->x;
|
startx = seg->v1->x;
|
||||||
|
@ -394,14 +398,18 @@ newseg:
|
||||||
// seg's ending vertex.
|
// seg's ending vertex.
|
||||||
for (i = 0; i < numsegs; ++i)
|
for (i = 0; i < numsegs; ++i)
|
||||||
{
|
{
|
||||||
|
size_t q;
|
||||||
|
|
||||||
if (segs[i].glseg)
|
if (segs[i].glseg)
|
||||||
continue;
|
continue;
|
||||||
if (segs[i].side != 0) // needs to be frontfacing
|
if (segs[i].side != 0) // needs to be frontfacing
|
||||||
continue;
|
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...
|
// Make sure you didn't already add this seg...
|
||||||
size_t q;
|
|
||||||
for (q = 0; q < po->segCount; q++)
|
for (q = 0; q < po->segCount; q++)
|
||||||
{
|
{
|
||||||
if (po->segs[q] == &segs[i])
|
if (po->segs[q] == &segs[i])
|
||||||
|
@ -420,13 +428,15 @@ newseg:
|
||||||
// Find backfacings
|
// Find backfacings
|
||||||
for (q = 0; q < numsegs; q++)
|
for (q = 0; q < numsegs; q++)
|
||||||
{
|
{
|
||||||
|
size_t r;
|
||||||
|
|
||||||
if (segs[q].glseg)
|
if (segs[q].glseg)
|
||||||
continue;
|
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])
|
if (po->segs[r] == &segs[q])
|
||||||
|
@ -440,11 +450,9 @@ newseg:
|
||||||
Polyobj_addSeg(po, &segs[q]);
|
Polyobj_addSeg(po, &segs[q]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
goto newseg;
|
goto newseg;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// error: if we reach here, the seg search never found another seg to
|
// 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.
|
// continue the loop, and thus the polyobject is open. This isn't allowed.
|
||||||
|
|
Loading…
Reference in a new issue