From 388c511e1153fc91456fe5fd3cc31032c22d5a41 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 9 Feb 2017 05:42:15 +0100 Subject: [PATCH] Fix portal sprite clipping bugs --- src/swrenderer/scene/r_3dfloors.h | 1 + src/swrenderer/scene/r_opaque_pass.h | 2 ++ src/swrenderer/scene/r_portal.cpp | 17 +++++++++-------- src/swrenderer/scene/r_scene.cpp | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/swrenderer/scene/r_3dfloors.h b/src/swrenderer/scene/r_3dfloors.h index 13168a80b..d697755b2 100644 --- a/src/swrenderer/scene/r_3dfloors.h +++ b/src/swrenderer/scene/r_3dfloors.h @@ -78,6 +78,7 @@ namespace swrenderer void EnterSkybox(); void LeaveSkybox(); void SetFakeFloor(F3DFloor *fakeFloor); + void ClearFakeFloors() { FakeFloors.clear(); } RenderThread *Thread = nullptr; diff --git a/src/swrenderer/scene/r_opaque_pass.h b/src/swrenderer/scene/r_opaque_pass.h index 6f0f06581..6a14703c5 100644 --- a/src/swrenderer/scene/r_opaque_pass.h +++ b/src/swrenderer/scene/r_opaque_pass.h @@ -60,6 +60,8 @@ namespace swrenderer void ResetFakingUnderwater() { r_fakingunderwater = false; } sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, seg_t *backline, int backx1, int backx2, double frontcz1, double frontcz2); + + void ClearSeenSprites() { SeenSpriteSectors.clear(); SeenActors.clear(); } short floorclip[MAXWIDTH]; short ceilingclip[MAXWIDTH]; diff --git a/src/swrenderer/scene/r_portal.cpp b/src/swrenderer/scene/r_portal.cpp index 9053ebf15..af120103c 100644 --- a/src/swrenderer/scene/r_portal.cpp +++ b/src/swrenderer/scene/r_portal.cpp @@ -162,7 +162,8 @@ namespace swrenderer viewsector = port->mDestination; assert(viewsector != nullptr); R_SetViewAngle(); - validcount++; // Make sure we see all sprites + Thread->OpaquePass->ClearSeenSprites(); + Thread->Clip3D->ClearFakeFloors(); planes->ClearKeepFakePlanes(); Thread->ClipSegments->Clear(pl->left, pl->right); @@ -185,6 +186,11 @@ namespace swrenderer } } + drawseglist->PushPortal(); + Thread->SpriteList->PushPortal(); + viewposStack.Push(ViewPos); + visplaneStack.Push(pl); + // Create a drawseg to clip sprites to the sky plane DrawSegment *draw_segment = Thread->FrameMemory->NewObject(); draw_segment->CurrentPortalUniq = CurrentPortalUniq; @@ -207,11 +213,6 @@ namespace swrenderer memcpy(draw_segment->sprtopclip, ceilingclip + pl->left, (pl->right - pl->left) * sizeof(short)); drawseglist->Push(draw_segment); - drawseglist->PushPortal(); - Thread->SpriteList->PushPortal(); - viewposStack.Push(ViewPos); - visplaneStack.Push(pl); - Thread->OpaquePass->RenderScene(); Thread->Clip3D->ResetClip(); // reset clips (floor/ceiling) planes->Render(); @@ -227,7 +228,7 @@ namespace swrenderer { // Masked textures and planes need the view coordinates restored for proper positioning. viewposStack.Pop(ViewPos); - + Thread->TranslucentPass->Render(); VisiblePlane *pl; @@ -236,7 +237,7 @@ namespace swrenderer { pl->Render(Thread, pl->Alpha, pl->Additive, true); } - + Thread->SpriteList->PopPortal(); drawseglist->PopPortal(); } diff --git a/src/swrenderer/scene/r_scene.cpp b/src/swrenderer/scene/r_scene.cpp index 905c0a097..f7b8c9c88 100644 --- a/src/swrenderer/scene/r_scene.cpp +++ b/src/swrenderer/scene/r_scene.cpp @@ -177,7 +177,7 @@ namespace swrenderer if (!r_scene_multithreaded) numThreads = 1; - if (numThreads != Threads.size()) + if (numThreads != (int)Threads.size()) { StopThreads(); StartThreads(numThreads);