mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-20 18:42:26 +00:00
- fix handling in the clipper for a new range that completely covers an existing one.
The handling for this was from the first draft of the clipper that made very different assumptions than the final version. This cannot simply delete the old range - it has to explicitly alter it and recursively insert the outer sub-ranges separately.
This commit is contained in:
parent
159409d5d2
commit
98258e0bb2
2 changed files with 16 additions and 14 deletions
|
@ -603,7 +603,7 @@ int BunchDrawer::FindClosestBunch()
|
|||
|
||||
}
|
||||
}
|
||||
//Printf("picked bunch starting at %d\n", Bunches[closest].startline);
|
||||
//Printf("picked bunch starting at sector %d, wall %d\n", sections[sectionLines[Bunches[closest].startline].section].sector, Bunches[closest].startline);
|
||||
return closest;
|
||||
}
|
||||
|
||||
|
@ -680,7 +680,7 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal)
|
|||
if (section->lines[i] >= (int)wall.Size()) inbunch = false;
|
||||
if (!inbunch)
|
||||
{
|
||||
//Printf("Starting bunch:\n\tWall %d\n", section->lines[i]);
|
||||
//Printf("Starting bunch, Sector %d\n\tWall %d\n", section->sector, section->lines[i]);
|
||||
inbunch = StartBunch(sectnum, section->lines[i], walang1, walang2, portal);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -201,10 +201,10 @@ void Clipper::Clear(binangle rangestart)
|
|||
if (visibleStart.asbam() != 0 || visibleEnd.asbam() != 0)
|
||||
{
|
||||
int vstart = int(visibleStart.asbam() - rangestart.asbam());
|
||||
if (vstart > 1) AddClipRange(0, vstart - 1);
|
||||
if (vstart > 1) AddClipRange(0, vstart);
|
||||
|
||||
int vend = int(visibleEnd.asbam() - rangestart.asbam());
|
||||
if (vend > 0 && vend < INT_MAX - 1) AddClipRange(vend + 1, INT_MAX);
|
||||
if (vend > 0 && vend < INT_MAX) AddClipRange(vend, INT_MAX);
|
||||
}
|
||||
|
||||
|
||||
|
@ -396,25 +396,27 @@ void Clipper::AddWindowRange(int start, int end, float topclip, float bottomclip
|
|||
|
||||
if (node->start >= start && node->end <= end)
|
||||
{
|
||||
if (node->topclip > node->bottomclip) // shortcut the common case where the old node is already closed.
|
||||
int nodestart = node->start, nodeend = node->end;
|
||||
if (node->topclip > node->bottomclip) // we only need to make adjustments to the old node if it is not closed.
|
||||
{
|
||||
float mtopclip = topclip, mbottomclip = bottomclip;
|
||||
mergeClip(node, mtopclip, mbottomclip, viewz);
|
||||
// if old range is a window, make some adjustments.
|
||||
if (mtopclip <= mbottomclip || (mtopclip <= node->topclip && mbottomclip >= node->bottomclip))
|
||||
// if the new window is closed, we must remove the old range and insert a closed one, so that it gets merged with its neighbours.
|
||||
if (mtopclip <= mbottomclip)
|
||||
{
|
||||
// if the new window is more narrow both on top and bottom, we can remove the old range.
|
||||
auto temp = node;
|
||||
node = node->next;
|
||||
RemoveRange(temp);
|
||||
continue;
|
||||
auto mynode = NewRange(nodestart, nodeend, 0, 0);
|
||||
InsertRange(node->prev, mynode);
|
||||
}
|
||||
else
|
||||
{
|
||||
// in all other cases we must adjust the node's top and bottom
|
||||
node->topclip = mtopclip;
|
||||
node->bottomclip = mbottomclip;
|
||||
}
|
||||
|
||||
// in all other cases we must adjust the node, and recursively process both sub-ranges.
|
||||
node->topclip = mtopclip;
|
||||
node->bottomclip = mbottomclip;
|
||||
}
|
||||
int nodestart = node->start, nodeend = node->end;
|
||||
// At this point it is just easier to recursively add the sub-ranges because we'd have to run the full program on both anyway,
|
||||
// We must ensure the the new ranges' length are > 0.
|
||||
if (start < nodestart) AddWindowRange(start, nodestart, topclip, bottomclip, viewz);
|
||||
|
|
Loading…
Reference in a new issue