diff --git a/src/swrenderer/line/r_line.cpp b/src/swrenderer/line/r_line.cpp index 3f663defd..1f68727b1 100644 --- a/src/swrenderer/line/r_line.cpp +++ b/src/swrenderer/line/r_line.cpp @@ -1055,7 +1055,7 @@ namespace swrenderer Clip3DFloors *clip3d = Thread->Clip3D.get(); // kg3D - fake planes clipping - if (clip3d->fake3D & FAKE3D_REFRESHCLIP) + if (clip3d->fake3D & FAKE3D_FAKEBACK) { auto ceilingclip = Thread->OpaquePass->ceilingclip; auto floorclip = Thread->OpaquePass->floorclip; diff --git a/src/swrenderer/line/r_renderdrawsegment.cpp b/src/swrenderer/line/r_renderdrawsegment.cpp index 3550b7356..e00b08f5f 100644 --- a/src/swrenderer/line/r_renderdrawsegment.cpp +++ b/src/swrenderer/line/r_renderdrawsegment.cpp @@ -123,8 +123,6 @@ namespace swrenderer } } - bool wrap = (curline->linedef->flags & ML_WRAP_MIDTEX) || (curline->sidedef->Flags & WALLF_WRAP_MIDTEX); - // [RH] Draw fog partition bool renderwall = true; bool notrelevant = false; @@ -145,7 +143,7 @@ namespace swrenderer } if (renderwall) - notrelevant = RenderWall(ds, x1, x2, walldrawerargs, columndrawerargs, visible, basecolormap, wallshade, wrap); + notrelevant = RenderWall(ds, x1, x2, walldrawerargs, columndrawerargs, visible, basecolormap, wallshade); if (ds->Has3DFloorFrontSectorWalls() || ds->Has3DFloorBackSectorWalls()) { @@ -153,22 +151,12 @@ namespace swrenderer } if (!notrelevant) { - if (clip3d->fake3D & FAKE3D_REFRESHCLIP) - { - if (!wrap) - { - assert(ds->bkup != nullptr); - memcpy(ds->sprtopclip, ds->bkup, (ds->x2 - ds->x1) * 2); - } - } - else - { - fillshort(ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight); - } + ds->sprclipped = true; + fillshort(ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight); } } - bool RenderDrawSegment::RenderWall(DrawSegment *ds, int x1, int x2, WallDrawerArgs &walldrawerargs, SpriteDrawerArgs &columndrawerargs, bool visible, FDynamicColormap *basecolormap, int wallshade, bool wrap) + bool RenderDrawSegment::RenderWall(DrawSegment *ds, int x1, int x2, WallDrawerArgs &walldrawerargs, SpriteDrawerArgs &columndrawerargs, bool visible, FDynamicColormap *basecolormap, int wallshade) { auto viewport = Thread->Viewport.get(); Clip3DFloors *clip3d = Thread->Clip3D.get(); @@ -220,6 +208,7 @@ namespace swrenderer double rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid); + bool wrap = (curline->linedef->flags & ML_WRAP_MIDTEX) || (curline->sidedef->Flags & WALLF_WRAP_MIDTEX); if (!wrap) { // Texture does not wrap vertically. double textop; diff --git a/src/swrenderer/line/r_renderdrawsegment.h b/src/swrenderer/line/r_renderdrawsegment.h index 42a5ac5bc..05a4b68c0 100644 --- a/src/swrenderer/line/r_renderdrawsegment.h +++ b/src/swrenderer/line/r_renderdrawsegment.h @@ -37,7 +37,7 @@ namespace swrenderer RenderThread *Thread = nullptr; private: - bool RenderWall(DrawSegment *ds, int x1, int x2, WallDrawerArgs &walldrawerargs, SpriteDrawerArgs &columndrawerargs, bool visible, FDynamicColormap *basecolormap, int wallshade, bool wrap); + bool RenderWall(DrawSegment *ds, int x1, int x2, WallDrawerArgs &walldrawerargs, SpriteDrawerArgs &columndrawerargs, bool visible, FDynamicColormap *basecolormap, int wallshade); void ClipMidtex(int x1, int x2); void RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap); void RenderFakeWallRange(DrawSegment *ds, int x1, int x2, int wallshade); diff --git a/src/swrenderer/scene/r_3dfloors.h b/src/swrenderer/scene/r_3dfloors.h index d697755b2..e1f52d166 100644 --- a/src/swrenderer/scene/r_3dfloors.h +++ b/src/swrenderer/scene/r_3dfloors.h @@ -49,7 +49,6 @@ namespace swrenderer // sorting stage: FAKE3D_CLIPBOTTOM = 1, // clip bottom FAKE3D_CLIPTOP = 2, // clip top - FAKE3D_REFRESHCLIP = 4, // refresh clip info FAKE3D_DOWN2UP = 8, // rendering from down to up (floors) }; diff --git a/src/swrenderer/scene/r_translucent_pass.cpp b/src/swrenderer/scene/r_translucent_pass.cpp index e08486ef9..76677a6a0 100644 --- a/src/swrenderer/scene/r_translucent_pass.cpp +++ b/src/swrenderer/scene/r_translucent_pass.cpp @@ -149,11 +149,6 @@ namespace swrenderer // render any remaining masked mid textures - if (renew) - { - Thread->Clip3D->fake3D |= FAKE3D_REFRESHCLIP; - } - for (unsigned int index = 0; index != drawseglist->SegmentsCount(); index++) { DrawSegment *ds = drawseglist->Segment(index); @@ -161,12 +156,18 @@ namespace swrenderer // [ZZ] the same as above if (ds->CurrentPortalUniq != renderportal->CurrentPortalUniq) continue; - if (ds->maskedtexturecol != nullptr || ds->bFogBoundary) + if (ds->maskedtexturecol || ds->bFogBoundary) { RenderDrawSegment renderer(Thread); renderer.Render(ds, ds->x1, ds->x2); if (renew && ds->bFogBoundary) // don't draw fogboundary again ds->bFogBoundary = false; + + if (renew && ds->sprclipped) + { + memcpy(ds->sprtopclip, ds->bkup, (ds->x2 - ds->x1) * sizeof(short)); + ds->sprclipped = false; + } } } } diff --git a/src/swrenderer/segments/r_drawsegment.h b/src/swrenderer/segments/r_drawsegment.h index c29b3a67a..4e2943ab0 100644 --- a/src/swrenderer/segments/r_drawsegment.h +++ b/src/swrenderer/segments/r_drawsegment.h @@ -47,6 +47,7 @@ namespace swrenderer fixed_t *maskedtexturecol = nullptr; float *swall = nullptr; short *bkup = nullptr; // sprtopclip backup, for mid and fake textures + bool sprclipped = false; // True if draw segment was used for clipping sprites FWallTmapVals tmapvals;