mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-29 07:22:05 +00:00
Convert r_clipsegment into a class
This commit is contained in:
parent
74e1cea9c3
commit
f6cc75fad5
6 changed files with 33 additions and 23 deletions
|
@ -91,7 +91,7 @@ namespace swrenderer
|
|||
|
||||
if (line->linedef == NULL)
|
||||
{
|
||||
if (R_CheckClipWallSegment(WallC.sx1, WallC.sx2))
|
||||
if (RenderClipSegment::Instance()->Check(WallC.sx1, WallC.sx2))
|
||||
{
|
||||
InSubsector->flags |= SSECF_DRAWN;
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ namespace swrenderer
|
|||
// mark their subsectors as visible for automap texturing.
|
||||
if (hasglnodes && !(InSubsector->flags & SSECF_DRAWN))
|
||||
{
|
||||
if (R_CheckClipWallSegment(WallC.sx1, WallC.sx2))
|
||||
if (RenderClipSegment::Instance()->Check(WallC.sx1, WallC.sx2))
|
||||
{
|
||||
InSubsector->flags |= SSECF_DRAWN;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ namespace swrenderer
|
|||
}
|
||||
|
||||
static SWRenderLine *self = this;
|
||||
bool visible = R_ClipWallSegment(WallC.sx1, WallC.sx2, solid, [](int x1, int x2) -> bool
|
||||
bool visible = RenderClipSegment::Instance()->Clip(WallC.sx1, WallC.sx2, solid, [](int x1, int x2) -> bool
|
||||
{
|
||||
return self->RenderWallSegment(x1, x2);
|
||||
});
|
||||
|
|
|
@ -378,7 +378,7 @@ namespace swrenderer
|
|||
// Find the first clippost that touches the source post
|
||||
// (adjacent pixels are touching).
|
||||
|
||||
return R_IsWallSegmentVisible(sx1, sx2);
|
||||
return RenderClipSegment::Instance()->IsVisible(sx1, sx2);
|
||||
}
|
||||
|
||||
void RenderOpaquePass::AddPolyobjs(subsector_t *sub)
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace swrenderer
|
|||
validcount++; // Make sure we see all sprites
|
||||
|
||||
planes->Clear(false);
|
||||
R_ClearClipSegs(pl->left, pl->right);
|
||||
RenderClipSegment::Instance()->Clear(pl->left, pl->right);
|
||||
WindowLeft = pl->left;
|
||||
WindowRight = pl->right;
|
||||
|
||||
|
@ -429,7 +429,7 @@ namespace swrenderer
|
|||
CurrentPortal = pds;
|
||||
|
||||
VisiblePlaneList::Instance()->Clear(false);
|
||||
R_ClearClipSegs(pds->x1, pds->x2);
|
||||
RenderClipSegment::Instance()->Clear(pds->x1, pds->x2);
|
||||
|
||||
WindowLeft = pds->x1;
|
||||
WindowRight = pds->x2;
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace swrenderer
|
|||
RenderPortal::Instance()->CopyStackedViewParameters();
|
||||
|
||||
// Clear buffers.
|
||||
R_ClearClipSegs(0, viewwidth);
|
||||
RenderClipSegment::Instance()->Clear(0, viewwidth);
|
||||
R_ClearDrawSegs();
|
||||
VisiblePlaneList::Instance()->Clear(true);
|
||||
RenderTranslucentPass::Clear();
|
||||
|
|
|
@ -34,18 +34,13 @@
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
namespace
|
||||
RenderClipSegment *RenderClipSegment::Instance()
|
||||
{
|
||||
struct cliprange_t
|
||||
{
|
||||
short first, last;
|
||||
};
|
||||
|
||||
cliprange_t *newend; // newend is one past the last valid seg
|
||||
cliprange_t solidsegs[MAXWIDTH / 2 + 2];
|
||||
static RenderClipSegment instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void R_ClearClipSegs(short left, short right)
|
||||
void RenderClipSegment::Clear(short left, short right)
|
||||
{
|
||||
solidsegs[0].first = -0x7fff;
|
||||
solidsegs[0].last = left;
|
||||
|
@ -54,7 +49,7 @@ namespace swrenderer
|
|||
newend = solidsegs+2;
|
||||
}
|
||||
|
||||
bool R_CheckClipWallSegment(int first, int last)
|
||||
bool RenderClipSegment::Check(int first, int last)
|
||||
{
|
||||
cliprange_t *start;
|
||||
|
||||
|
@ -78,7 +73,7 @@ namespace swrenderer
|
|||
return false;
|
||||
}
|
||||
|
||||
bool R_IsWallSegmentVisible(int sx1, int sx2)
|
||||
bool RenderClipSegment::IsVisible(int sx1, int sx2)
|
||||
{
|
||||
// Does not cross a pixel.
|
||||
if (sx2 <= sx1)
|
||||
|
@ -97,7 +92,7 @@ namespace swrenderer
|
|||
return true;
|
||||
}
|
||||
|
||||
bool R_ClipWallSegment(int first, int last, bool solid, VisibleSegmentCallback callback)
|
||||
bool RenderClipSegment::Clip(int first, int last, bool solid, VisibleSegmentCallback callback)
|
||||
{
|
||||
cliprange_t *next, *start;
|
||||
int i, j;
|
||||
|
|
|
@ -17,8 +17,23 @@ namespace swrenderer
|
|||
{
|
||||
typedef bool(*VisibleSegmentCallback)(int x1, int x2);
|
||||
|
||||
void R_ClearClipSegs(short left, short right);
|
||||
bool R_ClipWallSegment(int x1, int x2, bool solid, VisibleSegmentCallback callback);
|
||||
bool R_CheckClipWallSegment(int first, int last);
|
||||
bool R_IsWallSegmentVisible(int x1, int x2);
|
||||
class RenderClipSegment
|
||||
{
|
||||
public:
|
||||
static RenderClipSegment *Instance();
|
||||
|
||||
void Clear(short left, short right);
|
||||
bool Clip(int x1, int x2, bool solid, VisibleSegmentCallback callback);
|
||||
bool Check(int first, int last);
|
||||
bool IsVisible(int x1, int x2);
|
||||
|
||||
private:
|
||||
struct cliprange_t
|
||||
{
|
||||
short first, last;
|
||||
};
|
||||
|
||||
cliprange_t *newend; // newend is one past the last valid seg
|
||||
cliprange_t solidsegs[MAXWIDTH / 2 + 2];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue