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