From 86975a71e8b4e7da68265d2841f9d838d22f7ab5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Jun 2018 10:50:48 +0200 Subject: [PATCH] - don't use r_viewpoint directly when sorting translucent geometry. Better store the view Z in a member variable and use that. --- src/hwrenderer/scene/hw_drawlist.cpp | 7 ++++--- src/hwrenderer/scene/hw_drawlist.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hwrenderer/scene/hw_drawlist.cpp b/src/hwrenderer/scene/hw_drawlist.cpp index 4d70e2f828..1df8d5763a 100644 --- a/src/hwrenderer/scene/hw_drawlist.cpp +++ b/src/hwrenderer/scene/hw_drawlist.cpp @@ -121,7 +121,7 @@ inline void SortNode::AddToEqual(SortNode *child) { child->UnlinkFromChain(); child->equal=equal; - equal=child; + equal=child; } //========================================================================== @@ -269,7 +269,7 @@ void HWDrawList::SortWallIntoPlane(SortNode * head, SortNode * sort) GLFlat * fh = flats[drawitems[head->itemindex].index]; GLWall * ws = walls[drawitems[sort->itemindex].index]; - bool ceiling = fh->z > r_viewpoint.Pos.Z; + bool ceiling = fh->z > SortZ; if ((ws->ztop[0] > fh->z || ws->ztop[1] > fh->z) && (ws->zbottom[0] < fh->z || ws->zbottom[1] < fh->z)) { @@ -327,7 +327,7 @@ void HWDrawList::SortSpriteIntoPlane(SortNode * head, SortNode * sort) GLFlat * fh = flats[drawitems[head->itemindex].index]; GLSprite * ss = sprites[drawitems[sort->itemindex].index]; - bool ceiling = fh->z > r_viewpoint.Pos.Z; + bool ceiling = fh->z > SortZ; auto hiz = ss->z1 > ss->z2 ? ss->z1 : ss->z2; auto loz = ss->z1 < ss->z2 ? ss->z1 : ss->z2; @@ -688,6 +688,7 @@ SortNode * HWDrawList::DoSort(HWDrawInfo *di, SortNode * head) //========================================================================== void HWDrawList::Sort(HWDrawInfo *di) { + SortZ = r_viewpoint.Pos.Z; MakeSortList(); sorted = DoSort(di, SortNodes[SortNodeStart]); } diff --git a/src/hwrenderer/scene/hw_drawlist.h b/src/hwrenderer/scene/hw_drawlist.h index 5e440df81d..22bf1cb31e 100644 --- a/src/hwrenderer/scene/hw_drawlist.h +++ b/src/hwrenderer/scene/hw_drawlist.h @@ -61,6 +61,7 @@ struct HWDrawList TArray sprites; TArray drawitems; int SortNodeStart; + float SortZ; SortNode * sorted; public: