diff --git a/src/swrenderer/scene/r_portal.cpp b/src/swrenderer/scene/r_portal.cpp index c6685ddae..af2832f01 100644 --- a/src/swrenderer/scene/r_portal.cpp +++ b/src/swrenderer/scene/r_portal.cpp @@ -239,7 +239,7 @@ namespace swrenderer // Masked textures and planes need the view coordinates restored for proper positioning. viewposStack.Pop(ViewPos); - RenderTranslucentPass::Render(); + RenderTranslucentPass::Instance()->Render(); drawseglist->ds_p = drawseglist->firstdrawseg; @@ -458,7 +458,7 @@ namespace swrenderer NetUpdate(); MaskedCycles.Clock(); // [ZZ] count sprites in portals/mirrors along with normal ones. - RenderTranslucentPass::Render(); // this is required since with portals there often will be cases when more than 80% of the view is inside a portal. + RenderTranslucentPass::Instance()->Render(); // this is required since with portals there often will be cases when more than 80% of the view is inside a portal. MaskedCycles.Unclock(); NetUpdate(); diff --git a/src/swrenderer/scene/r_scene.cpp b/src/swrenderer/scene/r_scene.cpp index 2d1e1d7bb..a85120eb3 100644 --- a/src/swrenderer/scene/r_scene.cpp +++ b/src/swrenderer/scene/r_scene.cpp @@ -134,7 +134,7 @@ namespace swrenderer RenderClipSegment::Instance()->Clear(0, viewwidth); DrawSegmentList::Instance()->Clear(); VisiblePlaneList::Instance()->Clear(); - RenderTranslucentPass::Clear(); + RenderTranslucentPass::Instance()->Clear(); // opening / clipping determination RenderOpaquePass::Instance()->ClearClip(); @@ -182,7 +182,7 @@ namespace swrenderer NetUpdate(); MaskedCycles.Clock(); - RenderTranslucentPass::Render(); + RenderTranslucentPass::Instance()->Render(); MaskedCycles.Unclock(); NetUpdate(); @@ -267,7 +267,7 @@ namespace swrenderer void RenderScene::Deinit() { - RenderTranslucentPass::Deinit(); + RenderTranslucentPass::Instance()->Deinit(); Clip3DFloors::Instance()->Cleanup(); DrawSegmentList::Instance()->Deinit(); } diff --git a/src/swrenderer/scene/r_translucent_pass.cpp b/src/swrenderer/scene/r_translucent_pass.cpp index 21e9a50df..862b47a71 100644 --- a/src/swrenderer/scene/r_translucent_pass.cpp +++ b/src/swrenderer/scene/r_translucent_pass.cpp @@ -47,8 +47,11 @@ CVAR(Bool, r_fullbrightignoresectorcolor, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG namespace swrenderer { - bool RenderTranslucentPass::DrewAVoxel; - TArray RenderTranslucentPass::portaldrawsegs; + RenderTranslucentPass *RenderTranslucentPass::Instance() + { + static RenderTranslucentPass instance; + return &instance; + } void RenderTranslucentPass::Deinit() { diff --git a/src/swrenderer/scene/r_translucent_pass.h b/src/swrenderer/scene/r_translucent_pass.h index 6bd675af1..6e5ea778d 100644 --- a/src/swrenderer/scene/r_translucent_pass.h +++ b/src/swrenderer/scene/r_translucent_pass.h @@ -28,18 +28,20 @@ namespace swrenderer class RenderTranslucentPass { public: - static void Deinit(); - static void Clear(); - static void Render(); + static RenderTranslucentPass *Instance(); - static bool DrewAVoxel; + void Deinit(); + void Clear(); + void Render(); - static bool ClipSpriteColumnWithPortals(int x, VisibleSprite *spr); + bool DrewAVoxel = false; + + bool ClipSpriteColumnWithPortals(int x, VisibleSprite *spr); private: - static void CollectPortals(); - static void DrawMaskedSingle(bool renew); + void CollectPortals(); + void DrawMaskedSingle(bool renew); - static TArray portaldrawsegs; + TArray portaldrawsegs; }; } diff --git a/src/swrenderer/things/r_particle.cpp b/src/swrenderer/things/r_particle.cpp index 47a36a719..f7a7ba94b 100644 --- a/src/swrenderer/things/r_particle.cpp +++ b/src/swrenderer/things/r_particle.cpp @@ -236,11 +236,13 @@ namespace swrenderer uint32_t fracstepx = PARTICLE_TEXTURE_SIZE * FRACUNIT / countbase; uint32_t fracposx = fracstepx / 2; + RenderTranslucentPass *translucentPass = RenderTranslucentPass::Instance(); + if (r_swtruecolor) { for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) { - if (RenderTranslucentPass::ClipSpriteColumnWithPortals(x, vis)) + if (translucentPass->ClipSpriteColumnWithPortals(x, vis)) continue; uint32_t *dest = ylookup[yl] + x + (uint32_t*)dc_destorg; DrawerCommandQueue::QueueCommand(dest, yl, spacing, ycount, fg, alpha, fracposx); @@ -250,7 +252,7 @@ namespace swrenderer { for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx) { - if (RenderTranslucentPass::ClipSpriteColumnWithPortals(x, vis)) + if (translucentPass->ClipSpriteColumnWithPortals(x, vis)) continue; uint8_t *dest = ylookup[yl] + x + dc_destorg; DrawerCommandQueue::QueueCommand(dest, yl, spacing, ycount, fg, alpha, fracposx); diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index 1c91c75b0..126a6942e 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -288,9 +288,11 @@ namespace swrenderer if (x < x2) { + RenderTranslucentPass *translucentPass = RenderTranslucentPass::Instance(); + while (x < x2) { - if (!RenderTranslucentPass::ClipSpriteColumnWithPortals(x, vis)) + if (!translucentPass->ClipSpriteColumnWithPortals(x, vis)) R_DrawMaskedColumn(x, iscale, tex, frac, spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, false); x++; frac += xiscale; diff --git a/src/swrenderer/things/r_voxel.cpp b/src/swrenderer/things/r_voxel.cpp index a4b44e008..481c2c378 100644 --- a/src/swrenderer/things/r_voxel.cpp +++ b/src/swrenderer/things/r_voxel.cpp @@ -178,7 +178,7 @@ namespace swrenderer vis->Light.SetColormap(r_SpriteVisibility / MAX(tz, MINZ), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack); VisibleSpriteList::Instance()->Push(vis); - RenderTranslucentPass::DrewAVoxel = true; + RenderTranslucentPass::Instance()->DrewAVoxel = true; } void RenderVoxel::Render(short *cliptop, short *clipbottom, int minZ, int maxZ) diff --git a/src/swrenderer/things/r_wallsprite.cpp b/src/swrenderer/things/r_wallsprite.cpp index a6da5ff0e..09d882b0f 100644 --- a/src/swrenderer/things/r_wallsprite.cpp +++ b/src/swrenderer/things/r_wallsprite.cpp @@ -226,13 +226,15 @@ namespace swrenderer } else { + RenderTranslucentPass *translucentPass = RenderTranslucentPass::Instance(); + while (x < x2) { if (calclighting) { // calculate lighting R_SetColorMapLight(usecolormap, light, shade); } - if (!RenderTranslucentPass::ClipSpriteColumnWithPortals(x, spr)) + if (!translucentPass->ClipSpriteColumnWithPortals(x, spr)) DrawColumn(x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip); light += lightstep; x++;