Fix portals draw segment indexing bug

This commit is contained in:
Magnus Norddahl 2017-02-09 22:58:28 +01:00
parent 6ed46921c8
commit 3c0d769499
4 changed files with 7 additions and 9 deletions

View file

@ -71,7 +71,7 @@ namespace swrenderer
// b) skip most of the collected drawsegs which have no portal attached. // b) skip most of the collected drawsegs which have no portal attached.
portaldrawsegs.Clear(); portaldrawsegs.Clear();
DrawSegmentList *drawseglist = Thread->DrawSegments.get(); DrawSegmentList *drawseglist = Thread->DrawSegments.get();
for (auto index = drawseglist->BeginIndex(); index != drawseglist->EndIndex(); index++) for (auto index = 0; index != drawseglist->SegmentsCount(); index++)
{ {
DrawSegment *seg = drawseglist->Segment(index); DrawSegment *seg = drawseglist->Segment(index);
@ -144,7 +144,7 @@ namespace swrenderer
} }
DrawSegmentList *drawseglist = Thread->DrawSegments.get(); DrawSegmentList *drawseglist = Thread->DrawSegments.get();
for (auto index = drawseglist->BeginIndex(); index != drawseglist->EndIndex(); index++) for (auto index = 0; index != drawseglist->SegmentsCount(); index++)
{ {
DrawSegment *ds = drawseglist->Segment(index); DrawSegment *ds = drawseglist->Segment(index);

View file

@ -90,13 +90,13 @@ namespace swrenderer
SegmentGroups.Clear(); SegmentGroups.Clear();
unsigned int groupSize = 100; unsigned int groupSize = 100;
for (unsigned int index = BeginIndex(); index < EndIndex(); index += groupSize) for (unsigned int index = 0; index < SegmentsCount(); index += groupSize)
{ {
auto ds = Segment(index); auto ds = Segment(index);
DrawSegmentGroup group; DrawSegmentGroup group;
group.BeginIndex = index; group.BeginIndex = index;
group.EndIndex = MIN(index + groupSize, EndIndex()); group.EndIndex = MIN(index + groupSize, SegmentsCount());
group.x1 = ds->x1; group.x1 = ds->x1;
group.x2 = ds->x2; group.x2 = ds->x2;
group.neardepth = MIN(ds->sz1, ds->sz2); group.neardepth = MIN(ds->sz1, ds->sz2);

View file

@ -64,12 +64,10 @@ namespace swrenderer
TArray<DrawSegmentGroup> SegmentGroups; TArray<DrawSegmentGroup> SegmentGroups;
unsigned int BeginIndex() const { return StartIndices.Last(); } unsigned int SegmentsCount() const { return Segments.Size() - StartIndices.Last(); }
unsigned int EndIndex() const { return Segments.Size(); }
DrawSegment *Segment(unsigned int index) const { return Segments[Segments.Size() - 1 - index]; } DrawSegment *Segment(unsigned int index) const { return Segments[Segments.Size() - 1 - index]; }
unsigned int BeginInterestingIndex() const { return StartInterestingIndices.Last(); } unsigned int InterestingSegmentsCount() const { return InterestingSegments.Size() - StartInterestingIndices.Last(); }
unsigned int EndInterestingIndex() const { return InterestingSegments.Size(); }
DrawSegment *InterestingSegment(unsigned int index) const { return InterestingSegments[InterestingSegments.Size() - 1 - index]; } DrawSegment *InterestingSegment(unsigned int index) const { return InterestingSegments[InterestingSegments.Size() - 1 - index]; }
void Clear(); void Clear();

View file

@ -267,7 +267,7 @@ namespace swrenderer
// Draw any masked textures behind this particle so that when the // Draw any masked textures behind this particle so that when the
// particle is drawn, it will be in front of them. // particle is drawn, it will be in front of them.
DrawSegmentList *segmentlist = thread->DrawSegments.get(); DrawSegmentList *segmentlist = thread->DrawSegments.get();
for (unsigned int index = segmentlist->BeginInterestingIndex(); index != segmentlist->EndInterestingIndex(); index++) for (unsigned int index = 0; index != segmentlist->InterestingSegmentsCount(); index++)
{ {
DrawSegment *ds = segmentlist->InterestingSegment(index); DrawSegment *ds = segmentlist->InterestingSegment(index);