mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-17 17:11:19 +00:00
Add some helpers on DrawSegmentClipInfo
This commit is contained in:
parent
5cc75af295
commit
88848f1d59
12 changed files with 122 additions and 75 deletions
|
@ -54,12 +54,15 @@
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
void RenderFogBoundary::Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, const ProjectedWallLight &wallLight)
|
void RenderFogBoundary::Render(RenderThread *thread, int x1, int x2, const DrawSegmentClipInfo& clip, const ProjectedWallLight &wallLight)
|
||||||
{
|
{
|
||||||
// This is essentially the same as R_MapVisPlane but with an extra step
|
// This is essentially the same as R_MapVisPlane but with an extra step
|
||||||
// to create new horizontal spans whenever the light changes enough that
|
// to create new horizontal spans whenever the light changes enough that
|
||||||
// we need to use a new colormap.
|
// we need to use a new colormap.
|
||||||
|
|
||||||
|
const short* uclip = clip.sprtopclip;
|
||||||
|
const short* dclip = clip.sprbottomclip;
|
||||||
|
|
||||||
int wallshade = LightVisibility::LightLevelToShade(wallLight.GetLightLevel(), wallLight.GetFoggy(), thread->Viewport.get());
|
int wallshade = LightVisibility::LightLevelToShade(wallLight.GetLightLevel(), wallLight.GetFoggy(), thread->Viewport.get());
|
||||||
int x = x2 - 1;
|
int x = x2 - 1;
|
||||||
int t2 = uclip[x];
|
int t2 = uclip[x];
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace swrenderer
|
||||||
class RenderFogBoundary
|
class RenderFogBoundary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, const ProjectedWallLight &wallLight);
|
void Render(RenderThread *thread, int x1, int x2, const DrawSegmentClipInfo &clip, const ProjectedWallLight &wallLight);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RenderSection(RenderThread *thread, int y, int y2, int x1);
|
void RenderSection(RenderThread *thread, int y, int y2, int x1);
|
||||||
|
|
|
@ -290,11 +290,6 @@ namespace swrenderer
|
||||||
int i;
|
int i;
|
||||||
bool maskedtexture = false;
|
bool maskedtexture = false;
|
||||||
|
|
||||||
#ifdef RANGECHECK
|
|
||||||
if (start >= viewwidth || start >= stop)
|
|
||||||
I_Error("Bad R_StoreWallRange: %i to %i", start, stop);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!rw_prepped)
|
if (!rw_prepped)
|
||||||
{
|
{
|
||||||
rw_prepped = true;
|
rw_prepped = true;
|
||||||
|
@ -329,10 +324,8 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
else if (mBackSector == NULL)
|
else if (mBackSector == NULL)
|
||||||
{
|
{
|
||||||
draw_segment->drawsegclip.sprtopclip = Thread->FrameMemory->AllocMemory<short>(stop - start);
|
draw_segment->drawsegclip.SetTopClip(Thread, start, stop, viewheight);
|
||||||
draw_segment->drawsegclip.sprbottomclip = Thread->FrameMemory->AllocMemory<short>(stop - start);
|
draw_segment->drawsegclip.SetBottomClip(Thread, start, stop, -1);
|
||||||
fillshort(draw_segment->drawsegclip.sprtopclip, stop - start, viewheight);
|
|
||||||
memset(draw_segment->drawsegclip.sprbottomclip, -1, (stop - start) * sizeof(short));
|
|
||||||
draw_segment->drawsegclip.silhouette = SIL_BOTH;
|
draw_segment->drawsegclip.silhouette = SIL_BOTH;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -361,14 +354,12 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
if (mDoorClosed || (mBackCeilingZ1 <= mFrontFloorZ1 && mBackCeilingZ2 <= mFrontFloorZ2))
|
if (mDoorClosed || (mBackCeilingZ1 <= mFrontFloorZ1 && mBackCeilingZ2 <= mFrontFloorZ2))
|
||||||
{
|
{
|
||||||
draw_segment->drawsegclip.sprbottomclip = Thread->FrameMemory->AllocMemory<short>(stop - start);
|
draw_segment->drawsegclip.SetBottomClip(Thread, start, stop, -1);
|
||||||
memset(draw_segment->drawsegclip.sprbottomclip, -1, (stop - start) * sizeof(short));
|
|
||||||
draw_segment->drawsegclip.silhouette |= SIL_BOTTOM;
|
draw_segment->drawsegclip.silhouette |= SIL_BOTTOM;
|
||||||
}
|
}
|
||||||
if (mDoorClosed || (mBackFloorZ1 >= mFrontCeilingZ1 && mBackFloorZ2 >= mFrontCeilingZ2))
|
if (mDoorClosed || (mBackFloorZ1 >= mFrontCeilingZ1 && mBackFloorZ2 >= mFrontCeilingZ2))
|
||||||
{ // killough 1/17/98, 2/8/98
|
{
|
||||||
draw_segment->drawsegclip.sprtopclip = Thread->FrameMemory->AllocMemory<short>(stop - start);
|
draw_segment->drawsegclip.SetTopClip(Thread, start, stop, viewheight);
|
||||||
fillshort(draw_segment->drawsegclip.sprtopclip, stop - start, viewheight);
|
|
||||||
draw_segment->drawsegclip.silhouette |= SIL_TOP;
|
draw_segment->drawsegclip.silhouette |= SIL_TOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,9 +398,7 @@ namespace swrenderer
|
||||||
maskedtexture = true;
|
maskedtexture = true;
|
||||||
|
|
||||||
// kg3D - backup for mid and fake walls
|
// kg3D - backup for mid and fake walls
|
||||||
draw_segment->drawsegclip.bkup = Thread->FrameMemory->AllocMemory<short>(stop - start);
|
draw_segment->drawsegclip.SetBackupClip(Thread, start, stop, Thread->OpaquePass->ceilingclip);
|
||||||
memcpy(draw_segment->drawsegclip.bkup, &Thread->OpaquePass->ceilingclip[start], sizeof(short)*(stop - start));
|
|
||||||
|
|
||||||
draw_segment->drawsegclip.bFogBoundary = IsFogBoundary(mFrontSector, mBackSector);
|
draw_segment->drawsegclip.bFogBoundary = IsFogBoundary(mFrontSector, mBackSector);
|
||||||
if (sidedef->GetTexture(side_t::mid).isValid())
|
if (sidedef->GetTexture(side_t::mid).isValid())
|
||||||
{
|
{
|
||||||
|
@ -449,14 +438,12 @@ namespace swrenderer
|
||||||
// save sprite clipping info
|
// save sprite clipping info
|
||||||
if (((draw_segment->drawsegclip.silhouette & SIL_TOP) || maskedtexture) && draw_segment->drawsegclip.sprtopclip == nullptr)
|
if (((draw_segment->drawsegclip.silhouette & SIL_TOP) || maskedtexture) && draw_segment->drawsegclip.sprtopclip == nullptr)
|
||||||
{
|
{
|
||||||
draw_segment->drawsegclip.sprtopclip = Thread->FrameMemory->AllocMemory<short>(stop - start);
|
draw_segment->drawsegclip.SetTopClip(Thread, start, stop, Thread->OpaquePass->ceilingclip);
|
||||||
memcpy(draw_segment->drawsegclip.sprtopclip, &Thread->OpaquePass->ceilingclip[start], sizeof(short)*(stop - start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((draw_segment->drawsegclip.silhouette & SIL_BOTTOM) || maskedtexture) && draw_segment->drawsegclip.sprbottomclip == nullptr)
|
if (((draw_segment->drawsegclip.silhouette & SIL_BOTTOM) || maskedtexture) && draw_segment->drawsegclip.sprbottomclip == nullptr)
|
||||||
{
|
{
|
||||||
draw_segment->drawsegclip.sprbottomclip = Thread->FrameMemory->AllocMemory<short>(stop - start);
|
draw_segment->drawsegclip.SetBottomClip(Thread, start, stop, Thread->OpaquePass->floorclip);
|
||||||
memcpy(draw_segment->drawsegclip.sprbottomclip, &Thread->OpaquePass->floorclip[start], sizeof(short)*(stop - start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maskedtexture && mLineSegment->sidedef->GetTexture(side_t::mid).isValid())
|
if (maskedtexture && mLineSegment->sidedef->GetTexture(side_t::mid).isValid())
|
||||||
|
|
|
@ -102,11 +102,8 @@ namespace swrenderer
|
||||||
// [RH] Draw fog partition
|
// [RH] Draw fog partition
|
||||||
if (ds->drawsegclip.bFogBoundary)
|
if (ds->drawsegclip.bFogBoundary)
|
||||||
{
|
{
|
||||||
const short *mfloorclip = ds->drawsegclip.sprbottomclip - ds->x1;
|
|
||||||
const short *mceilingclip = ds->drawsegclip.sprtopclip - ds->x1;
|
|
||||||
|
|
||||||
RenderFogBoundary renderfog;
|
RenderFogBoundary renderfog;
|
||||||
renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, mLight);
|
renderfog.Render(Thread, x1, x2, ds->drawsegclip, mLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool notrelevant = false;
|
bool notrelevant = false;
|
||||||
|
@ -120,8 +117,7 @@ namespace swrenderer
|
||||||
|
|
||||||
if (!notrelevant)
|
if (!notrelevant)
|
||||||
{
|
{
|
||||||
ds->drawsegclip.sprclipped = true;
|
ds->drawsegclip.SetRangeDrawn(x1, x2);
|
||||||
fillshort(ds->drawsegclip.sprtopclip - ds->x1 + x1, x2 - x1, viewheight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +137,8 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
||||||
|
|
||||||
const short *mfloorclip = ds->drawsegclip.sprbottomclip - ds->x1;
|
const short *mfloorclip = ds->drawsegclip.sprbottomclip;
|
||||||
const short *mceilingclip = ds->drawsegclip.sprtopclip - ds->x1;
|
const short *mceilingclip = ds->drawsegclip.sprtopclip;
|
||||||
|
|
||||||
bool wrap = (curline->linedef->flags & ML_WRAP_MIDTEX) || (curline->sidedef->Flags & WALLF_WRAP_MIDTEX);
|
bool wrap = (curline->linedef->flags & ML_WRAP_MIDTEX) || (curline->sidedef->Flags & WALLF_WRAP_MIDTEX);
|
||||||
if (!wrap)
|
if (!wrap)
|
||||||
|
@ -214,16 +210,8 @@ namespace swrenderer
|
||||||
wallupper.Project(Thread->Viewport.get(), ceilZ, &ds->WallC);
|
wallupper.Project(Thread->Viewport.get(), ceilZ, &ds->WallC);
|
||||||
walllower.Project(Thread->Viewport.get(), floorZ, &ds->WallC);
|
walllower.Project(Thread->Viewport.get(), floorZ, &ds->WallC);
|
||||||
|
|
||||||
for (int i = x1; i < x2; i++)
|
wallupper.ClipTop(x1, x2, ds->drawsegclip);
|
||||||
{
|
walllower.ClipBottom(x1, x2, ds->drawsegclip);
|
||||||
if (wallupper.ScreenY[i] < mceilingclip[i])
|
|
||||||
wallupper.ScreenY[i] = mceilingclip[i];
|
|
||||||
}
|
|
||||||
for (int i = x1; i < x2; i++)
|
|
||||||
{
|
|
||||||
if (walllower.ScreenY[i] > mfloorclip[i])
|
|
||||||
walllower.ScreenY[i] = mfloorclip[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clip3d->CurrentSkybox)
|
if (clip3d->CurrentSkybox)
|
||||||
{ // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor
|
{ // Midtex clipping doesn't work properly with skyboxes, since you're normally below the floor
|
||||||
|
@ -297,23 +285,12 @@ namespace swrenderer
|
||||||
|
|
||||||
mLight.SetLightLeft(ds->light, ds->lightstep, ds->x1);
|
mLight.SetLightLeft(ds->light, ds->lightstep, ds->x1);
|
||||||
|
|
||||||
const short *mfloorclip = ds->drawsegclip.sprbottomclip - ds->x1;
|
|
||||||
const short *mceilingclip = ds->drawsegclip.sprtopclip - ds->x1;
|
|
||||||
|
|
||||||
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
||||||
wallupper.Project(Thread->Viewport.get(), clipTop - Thread->Viewport->viewpoint.Pos.Z, &ds->WallC);
|
wallupper.Project(Thread->Viewport.get(), clipTop - Thread->Viewport->viewpoint.Pos.Z, &ds->WallC);
|
||||||
walllower.Project(Thread->Viewport.get(), clipBottom - Thread->Viewport->viewpoint.Pos.Z, &ds->WallC);
|
walllower.Project(Thread->Viewport.get(), clipBottom - Thread->Viewport->viewpoint.Pos.Z, &ds->WallC);
|
||||||
|
|
||||||
for (int i = x1; i < x2; i++)
|
wallupper.ClipTop(x1, x2, ds->drawsegclip);
|
||||||
{
|
walllower.ClipBottom(x1, x2, ds->drawsegclip);
|
||||||
if (wallupper.ScreenY[i] < mceilingclip[i])
|
|
||||||
wallupper.ScreenY[i] = mceilingclip[i];
|
|
||||||
}
|
|
||||||
for (int i = x1; i < x2; i++)
|
|
||||||
{
|
|
||||||
if (walllower.ScreenY[i] > mfloorclip[i])
|
|
||||||
walllower.ScreenY[i] = mfloorclip[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectedWallTexcoords walltexcoords;
|
ProjectedWallTexcoords walltexcoords;
|
||||||
walltexcoords.Project3DFloor(Thread->Viewport.get(), rover, curline, ds->WallC.sx1, ds->WallC.sx2, ds->tmapvals, rw_pic);
|
walltexcoords.Project3DFloor(Thread->Viewport.get(), rover, curline, ds->WallC.sx1, ds->WallC.sx2, ds->tmapvals, rw_pic);
|
||||||
|
|
|
@ -168,6 +168,22 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectedWallLine::ClipTop(int x1, int x2, const DrawSegmentClipInfo& clip)
|
||||||
|
{
|
||||||
|
for (int i = x1; i < x2; i++)
|
||||||
|
{
|
||||||
|
ScreenY[i] = std::max(ScreenY[i], clip.sprtopclip[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectedWallLine::ClipBottom(int x1, int x2, const DrawSegmentClipInfo& clip)
|
||||||
|
{
|
||||||
|
for (int i = x1; i < x2; i++)
|
||||||
|
{
|
||||||
|
ScreenY[i] = std::min(ScreenY[i], clip.sprbottomclip[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void FWallTmapVals::InitFromWallCoords(RenderThread* thread, const FWallCoords* wallc)
|
void FWallTmapVals::InitFromWallCoords(RenderThread* thread, const FWallCoords* wallc)
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
struct FWallCoords;
|
struct FWallCoords;
|
||||||
|
struct DrawSegmentClipInfo;
|
||||||
|
|
||||||
enum class ProjectedWallCull
|
enum class ProjectedWallCull
|
||||||
{
|
{
|
||||||
|
@ -44,6 +45,9 @@ namespace swrenderer
|
||||||
ProjectedWallCull Project(RenderViewport *viewport, double z1, double z2, const FWallCoords *wallc);
|
ProjectedWallCull Project(RenderViewport *viewport, double z1, double z2, const FWallCoords *wallc);
|
||||||
ProjectedWallCull Project(RenderViewport *viewport, const secplane_t &plane, const FWallCoords *wallc, seg_t *line, bool xflip);
|
ProjectedWallCull Project(RenderViewport *viewport, const secplane_t &plane, const FWallCoords *wallc, seg_t *line, bool xflip);
|
||||||
ProjectedWallCull Project(RenderViewport *viewport, double z, const FWallCoords *wallc);
|
ProjectedWallCull Project(RenderViewport *viewport, double z, const FWallCoords *wallc);
|
||||||
|
|
||||||
|
void ClipTop(int x1, int x2, const DrawSegmentClipInfo& clip);
|
||||||
|
void ClipBottom(int x1, int x2, const DrawSegmentClipInfo& clip);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FWallTmapVals
|
struct FWallTmapVals
|
||||||
|
|
|
@ -212,12 +212,10 @@ namespace swrenderer
|
||||||
draw_segment->x1 = pl->left;
|
draw_segment->x1 = pl->left;
|
||||||
draw_segment->x2 = pl->right;
|
draw_segment->x2 = pl->right;
|
||||||
draw_segment->drawsegclip.silhouette = SIL_BOTH;
|
draw_segment->drawsegclip.silhouette = SIL_BOTH;
|
||||||
draw_segment->drawsegclip.sprbottomclip = Thread->FrameMemory->AllocMemory<short>(pl->right - pl->left);
|
draw_segment->drawsegclip.SetTopClip(Thread, pl->left, pl->right, ceilingclip);
|
||||||
draw_segment->drawsegclip.sprtopclip = Thread->FrameMemory->AllocMemory<short>(pl->right - pl->left);
|
draw_segment->drawsegclip.SetBottomClip(Thread, pl->left, pl->right, floorclip);
|
||||||
draw_segment->drawsegclip.bFogBoundary = false;
|
draw_segment->drawsegclip.bFogBoundary = false;
|
||||||
draw_segment->curline = nullptr;
|
draw_segment->curline = nullptr;
|
||||||
memcpy(draw_segment->drawsegclip.sprbottomclip, floorclip + pl->left, (pl->right - pl->left) * sizeof(short));
|
|
||||||
memcpy(draw_segment->drawsegclip.sprtopclip, ceilingclip + pl->left, (pl->right - pl->left) * sizeof(short));
|
|
||||||
drawseglist->Push(draw_segment);
|
drawseglist->Push(draw_segment);
|
||||||
|
|
||||||
Thread->OpaquePass->RenderScene(Thread->Viewport->Level());
|
Thread->OpaquePass->RenderScene(Thread->Viewport->Level());
|
||||||
|
|
|
@ -156,17 +156,15 @@ namespace swrenderer
|
||||||
// [ZZ] the same as above
|
// [ZZ] the same as above
|
||||||
if (ds->drawsegclip.CurrentPortalUniq != renderportal->CurrentPortalUniq)
|
if (ds->drawsegclip.CurrentPortalUniq != renderportal->CurrentPortalUniq)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ds->texcoords || ds->drawsegclip.bFogBoundary)
|
if (ds->texcoords || ds->drawsegclip.bFogBoundary)
|
||||||
{
|
{
|
||||||
RenderDrawSegment renderer(Thread);
|
RenderDrawSegment renderer(Thread);
|
||||||
renderer.Render(ds, ds->x1, ds->x2, clip3DFloor);
|
renderer.Render(ds, ds->x1, ds->x2, clip3DFloor);
|
||||||
if (renew && ds->drawsegclip.bFogBoundary) // don't draw fogboundary again
|
if (renew)
|
||||||
ds->drawsegclip.bFogBoundary = false;
|
|
||||||
|
|
||||||
if (renew && ds->drawsegclip.sprclipped)
|
|
||||||
{
|
{
|
||||||
memcpy(ds->drawsegclip.sprtopclip, ds->drawsegclip.bkup, (ds->x2 - ds->x1) * sizeof(short));
|
ds->drawsegclip.bFogBoundary = false; // don't draw fogboundary again
|
||||||
ds->drawsegclip.sprclipped = false;
|
ds->drawsegclip.SetRangeUndrawn(ds->x1, ds->x2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace swrenderer
|
||||||
if (ds->drawsegclip.silhouette & SIL_BOTTOM)
|
if (ds->drawsegclip.silhouette & SIL_BOTTOM)
|
||||||
{
|
{
|
||||||
short *clip1 = clipbottom + ds->x1;
|
short *clip1 = clipbottom + ds->x1;
|
||||||
const short *clip2 = ds->drawsegclip.sprbottomclip;
|
const short *clip2 = ds->drawsegclip.sprbottomclip + ds->x1;
|
||||||
int i = ds->x2 - ds->x1;
|
int i = ds->x2 - ds->x1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ namespace swrenderer
|
||||||
if (ds->drawsegclip.silhouette & SIL_TOP)
|
if (ds->drawsegclip.silhouette & SIL_TOP)
|
||||||
{
|
{
|
||||||
short *clip1 = cliptop + ds->x1;
|
short *clip1 = cliptop + ds->x1;
|
||||||
const short *clip2 = ds->drawsegclip.sprtopclip;
|
const short *clip2 = ds->drawsegclip.sprtopclip + ds->x1;
|
||||||
int i = ds->x2 - ds->x1;
|
int i = ds->x2 - ds->x1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -168,4 +168,58 @@ namespace swrenderer
|
||||||
SegmentGroups.Push(group);
|
SegmentGroups.Push(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void DrawSegmentClipInfo::SetTopClip(RenderThread* thread, int x1, int x2, const short* ceilingclip)
|
||||||
|
{
|
||||||
|
short* clip = thread->FrameMemory->AllocMemory<short>(x2 - x1);
|
||||||
|
memcpy(clip, ceilingclip + x1, (x2 - x1) * sizeof(short));
|
||||||
|
sprtopclip = clip - x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawSegmentClipInfo::SetTopClip(RenderThread* thread, int x1, int x2, short value)
|
||||||
|
{
|
||||||
|
short* clip = thread->FrameMemory->AllocMemory<short>(x2 - x1);
|
||||||
|
for (int i = 0; i < x2 - x1; i++)
|
||||||
|
clip[i] = value;
|
||||||
|
sprtopclip = clip - x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawSegmentClipInfo::SetBottomClip(RenderThread* thread, int x1, int x2, const short* floorclip)
|
||||||
|
{
|
||||||
|
short* clip = thread->FrameMemory->AllocMemory<short>(x2 - x1);
|
||||||
|
memcpy(clip, floorclip + x1, (x2 - x1) * sizeof(short));
|
||||||
|
sprbottomclip = clip - x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawSegmentClipInfo::SetBottomClip(RenderThread* thread, int x1, int x2, short value)
|
||||||
|
{
|
||||||
|
short* clip = thread->FrameMemory->AllocMemory<short>(x2 - x1);
|
||||||
|
for (int i = 0; i < x2 - x1; i++)
|
||||||
|
clip[i] = value;
|
||||||
|
sprbottomclip = clip - x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawSegmentClipInfo::SetBackupClip(RenderThread* thread, int x1, int x2, const short* ceilingclip)
|
||||||
|
{
|
||||||
|
short* clip = thread->FrameMemory->AllocMemory<short>(x2 - x1);
|
||||||
|
memcpy(clip, ceilingclip + x1, (x2 - x1) * sizeof(short));
|
||||||
|
bkup = clip - x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawSegmentClipInfo::SetRangeDrawn(int x1, int x2)
|
||||||
|
{
|
||||||
|
sprclipped = true;
|
||||||
|
fillshort(const_cast<short*>(sprtopclip) + x1, x2 - x1, viewheight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawSegmentClipInfo::SetRangeUndrawn(int x1, int x2)
|
||||||
|
{
|
||||||
|
if (sprclipped)
|
||||||
|
{
|
||||||
|
sprclipped = false;
|
||||||
|
memcpy(const_cast<short*>(sprtopclip) + x1, bkup + x1, (x2 - x1) * sizeof(short));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,16 +27,26 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
struct DrawSegmentClipInfo
|
struct DrawSegmentClipInfo
|
||||||
{
|
{
|
||||||
// Pointers to lists for sprite clipping, all three adjusted so [x1] is first value.
|
void SetTopClip(RenderThread* thread, int x1, int x2, const short* ceilingclip);
|
||||||
short* sprtopclip = nullptr;
|
void SetTopClip(RenderThread* thread, int x1, int x2, short value);
|
||||||
short* sprbottomclip = nullptr;
|
void SetBottomClip(RenderThread* thread, int x1, int x2, const short* floorclip);
|
||||||
short* bkup = nullptr; // sprtopclip backup, for translucent and 3d floor walls
|
void SetBottomClip(RenderThread* thread, int x1, int x2, short value);
|
||||||
|
void SetBackupClip(RenderThread* thread, int x1, int x2, const short* ceilingclip);
|
||||||
|
void SetRangeDrawn(int x1, int x2);
|
||||||
|
void SetRangeUndrawn(int x1, int x2);
|
||||||
|
|
||||||
bool sprclipped = false; // True if draw segment was used for clipping sprites
|
|
||||||
uint8_t silhouette = 0; // 0=none, 1=bottom, 2=top, 3=both
|
uint8_t silhouette = 0; // 0=none, 1=bottom, 2=top, 3=both
|
||||||
bool bFogBoundary = false;
|
bool bFogBoundary = false;
|
||||||
int CurrentPortalUniq = 0; // [ZZ] to identify the portal that this drawseg is in. used for sprite clipping.
|
int CurrentPortalUniq = 0; // [ZZ] to identify the portal that this drawseg is in. used for sprite clipping.
|
||||||
int SubsectorDepth;
|
int SubsectorDepth;
|
||||||
|
|
||||||
|
// Pointers to lists for sprite clipping, all three adjusted so [x1] is first value.
|
||||||
|
const short* sprtopclip = nullptr;
|
||||||
|
const short* sprbottomclip = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool sprclipped = false; // True if draw segment was used for clipping sprites
|
||||||
|
const short* bkup = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DrawSegment
|
struct DrawSegment
|
||||||
|
|
|
@ -52,8 +52,8 @@ namespace swrenderer
|
||||||
|
|
||||||
ceilingclip = thread->FrameMemory->AllocMemory<short>(len);
|
ceilingclip = thread->FrameMemory->AllocMemory<short>(len);
|
||||||
floorclip = thread->FrameMemory->AllocMemory<short>(len);
|
floorclip = thread->FrameMemory->AllocMemory<short>(len);
|
||||||
memcpy(ceilingclip, topclip, len * sizeof(short));
|
memcpy(ceilingclip, topclip + x1, len * sizeof(short));
|
||||||
memcpy(floorclip, bottomclip, len * sizeof(short));
|
memcpy(floorclip, bottomclip + x1, len * sizeof(short));
|
||||||
|
|
||||||
for (int i = 0; i < x2 - x1; i++)
|
for (int i = 0; i < x2 - x1; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -434,7 +434,7 @@ namespace swrenderer
|
||||||
if (ds->drawsegclip.silhouette & SIL_BOTTOM) //bottom sil
|
if (ds->drawsegclip.silhouette & SIL_BOTTOM) //bottom sil
|
||||||
{
|
{
|
||||||
short *clip1 = clipbot + r1;
|
short *clip1 = clipbot + r1;
|
||||||
const short *clip2 = ds->drawsegclip.sprbottomclip + r1 - ds->x1;
|
const short *clip2 = ds->drawsegclip.sprbottomclip + r1;
|
||||||
int i = r2 - r1;
|
int i = r2 - r1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -448,7 +448,7 @@ namespace swrenderer
|
||||||
if (ds->drawsegclip.silhouette & SIL_TOP) // top sil
|
if (ds->drawsegclip.silhouette & SIL_TOP) // top sil
|
||||||
{
|
{
|
||||||
short *clip1 = cliptop + r1;
|
short *clip1 = cliptop + r1;
|
||||||
const short *clip2 = ds->drawsegclip.sprtopclip + r1 - ds->x1;
|
const short *clip2 = ds->drawsegclip.sprtopclip + r1;
|
||||||
int i = r2 - r1;
|
int i = r2 - r1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue