Fix portal sprite clipping bugs

This commit is contained in:
Magnus Norddahl 2017-02-09 05:42:15 +01:00
parent 5948c7b0da
commit 388c511e11
4 changed files with 13 additions and 9 deletions

View file

@ -78,6 +78,7 @@ namespace swrenderer
void EnterSkybox(); void EnterSkybox();
void LeaveSkybox(); void LeaveSkybox();
void SetFakeFloor(F3DFloor *fakeFloor); void SetFakeFloor(F3DFloor *fakeFloor);
void ClearFakeFloors() { FakeFloors.clear(); }
RenderThread *Thread = nullptr; RenderThread *Thread = nullptr;

View file

@ -61,6 +61,8 @@ namespace swrenderer
void ResetFakingUnderwater() { r_fakingunderwater = false; } 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); 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 floorclip[MAXWIDTH];
short ceilingclip[MAXWIDTH]; short ceilingclip[MAXWIDTH];

View file

@ -162,7 +162,8 @@ namespace swrenderer
viewsector = port->mDestination; viewsector = port->mDestination;
assert(viewsector != nullptr); assert(viewsector != nullptr);
R_SetViewAngle(); R_SetViewAngle();
validcount++; // Make sure we see all sprites Thread->OpaquePass->ClearSeenSprites();
Thread->Clip3D->ClearFakeFloors();
planes->ClearKeepFakePlanes(); planes->ClearKeepFakePlanes();
Thread->ClipSegments->Clear(pl->left, pl->right); 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 // Create a drawseg to clip sprites to the sky plane
DrawSegment *draw_segment = Thread->FrameMemory->NewObject<DrawSegment>(); DrawSegment *draw_segment = Thread->FrameMemory->NewObject<DrawSegment>();
draw_segment->CurrentPortalUniq = CurrentPortalUniq; draw_segment->CurrentPortalUniq = CurrentPortalUniq;
@ -207,11 +213,6 @@ namespace swrenderer
memcpy(draw_segment->sprtopclip, ceilingclip + pl->left, (pl->right - pl->left) * sizeof(short)); memcpy(draw_segment->sprtopclip, ceilingclip + pl->left, (pl->right - pl->left) * sizeof(short));
drawseglist->Push(draw_segment); drawseglist->Push(draw_segment);
drawseglist->PushPortal();
Thread->SpriteList->PushPortal();
viewposStack.Push(ViewPos);
visplaneStack.Push(pl);
Thread->OpaquePass->RenderScene(); Thread->OpaquePass->RenderScene();
Thread->Clip3D->ResetClip(); // reset clips (floor/ceiling) Thread->Clip3D->ResetClip(); // reset clips (floor/ceiling)
planes->Render(); planes->Render();

View file

@ -177,7 +177,7 @@ namespace swrenderer
if (!r_scene_multithreaded) if (!r_scene_multithreaded)
numThreads = 1; numThreads = 1;
if (numThreads != Threads.size()) if (numThreads != (int)Threads.size())
{ {
StopThreads(); StopThreads();
StartThreads(numThreads); StartThreads(numThreads);