mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- fixed midtex nowrap clipping bug when 3d floors are in view
- made sure no code uses sclipTop or sclipBottom as a working variable
This commit is contained in:
parent
53a9819283
commit
2589447d0e
3 changed files with 43 additions and 42 deletions
|
@ -103,17 +103,13 @@ namespace swrenderer
|
||||||
|
|
||||||
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
||||||
|
|
||||||
if (!(m3DFloor.clipTop))
|
|
||||||
{
|
|
||||||
m3DFloor.sclipTop = sec->ceilingplane.ZatPoint(Thread->Viewport->viewpoint.Pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
CameraLight *cameraLight = CameraLight::Instance();
|
CameraLight *cameraLight = CameraLight::Instance();
|
||||||
if (cameraLight->FixedLightLevel() < 0)
|
if (cameraLight->FixedLightLevel() < 0)
|
||||||
{
|
{
|
||||||
|
double clipTop = m3DFloor.clipTop ? m3DFloor.sclipTop : sec->ceilingplane.ZatPoint(Thread->Viewport->viewpoint.Pos);
|
||||||
for (int i = frontsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
|
for (int i = frontsector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (m3DFloor.sclipTop <= frontsector->e->XFloor.lightlist[i].plane.Zat0())
|
if (clipTop <= frontsector->e->XFloor.lightlist[i].plane.Zat0())
|
||||||
{
|
{
|
||||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
||||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||||
|
@ -267,13 +263,18 @@ namespace swrenderer
|
||||||
WallC.sx1 = ds->sx1;
|
WallC.sx1 = ds->sx1;
|
||||||
WallC.sx2 = ds->sx2;
|
WallC.sx2 = ds->sx2;
|
||||||
|
|
||||||
|
double top, bot;
|
||||||
|
GetMaskedWallTopBottom(ds, top, bot);
|
||||||
|
top -= Thread->Viewport->viewpoint.Pos.Z;
|
||||||
|
bot -= Thread->Viewport->viewpoint.Pos.Z;
|
||||||
|
|
||||||
if (m3DFloor.clipTop)
|
if (m3DFloor.clipTop)
|
||||||
{
|
{
|
||||||
wallupper.Project(Thread->Viewport.get(), textop < m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z ? textop : m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
wallupper.Project(Thread->Viewport.get(), textop < m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z ? textop : m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wallupper.Project(Thread->Viewport.get(), textop, &WallC);
|
wallupper.Project(Thread->Viewport.get(), MIN(textop, top), &WallC);
|
||||||
}
|
}
|
||||||
if (m3DFloor.clipBottom)
|
if (m3DFloor.clipBottom)
|
||||||
{
|
{
|
||||||
|
@ -281,7 +282,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
walllower.Project(Thread->Viewport.get(), textop - texheight, &WallC);
|
walllower.Project(Thread->Viewport.get(), MAX(textop - texheight, bot), &WallC);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = x1; i < x2; i++)
|
for (int i = x1; i < x2; i++)
|
||||||
|
@ -402,7 +403,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
// kg3D - render one fake wall
|
// kg3D - render one fake wall
|
||||||
void RenderDrawSegment::RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap)
|
void RenderDrawSegment::RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap, double clipTop, double clipBottom)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double xscale;
|
double xscale;
|
||||||
|
@ -485,8 +486,8 @@ namespace swrenderer
|
||||||
WallT = ds->tmapvals;
|
WallT = ds->tmapvals;
|
||||||
|
|
||||||
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
||||||
wallupper.Project(Thread->Viewport.get(), m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
wallupper.Project(Thread->Viewport.get(), clipTop - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
||||||
walllower.Project(Thread->Viewport.get(), m3DFloor.sclipBottom - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
walllower.Project(Thread->Viewport.get(), clipBottom - Thread->Viewport->viewpoint.Pos.Z, &WallC);
|
||||||
|
|
||||||
for (i = x1; i < x2; i++)
|
for (i = x1; i < x2; i++)
|
||||||
{
|
{
|
||||||
|
@ -542,13 +543,12 @@ namespace swrenderer
|
||||||
|
|
||||||
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
||||||
|
|
||||||
// maybe fix clipheights
|
double clipTop = m3DFloor.clipTop ? m3DFloor.sclipTop : ceilingHeight;
|
||||||
if (!m3DFloor.clipBottom) m3DFloor.sclipBottom = floorHeight;
|
double clipBottom = m3DFloor.clipBottom ? m3DFloor.sclipBottom : floorHeight;
|
||||||
if (!m3DFloor.clipTop) m3DFloor.sclipTop = ceilingHeight;
|
|
||||||
|
|
||||||
// maybe not visible
|
// maybe not visible
|
||||||
if (m3DFloor.sclipBottom >= frontsector->CenterCeiling()) return;
|
if (clipBottom >= frontsector->CenterCeiling()) return;
|
||||||
if (m3DFloor.sclipTop <= frontsector->CenterFloor()) return;
|
if (clipTop <= frontsector->CenterFloor()) return;
|
||||||
|
|
||||||
if (m3DFloor.down2Up)
|
if (m3DFloor.down2Up)
|
||||||
{ // bottom to viewz
|
{ // bottom to viewz
|
||||||
|
@ -561,7 +561,7 @@ namespace swrenderer
|
||||||
// visible?
|
// visible?
|
||||||
passed = 0;
|
passed = 0;
|
||||||
if (!(rover->flags & FF_RENDERSIDES) || rover->top.plane->isSlope() || rover->bottom.plane->isSlope() ||
|
if (!(rover->flags & FF_RENDERSIDES) || rover->top.plane->isSlope() || rover->bottom.plane->isSlope() ||
|
||||||
rover->top.plane->Zat0() <= m3DFloor.sclipBottom ||
|
rover->top.plane->Zat0() <= clipBottom ||
|
||||||
rover->bottom.plane->Zat0() >= ceilingHeight ||
|
rover->bottom.plane->Zat0() >= ceilingHeight ||
|
||||||
rover->top.plane->Zat0() <= floorHeight)
|
rover->top.plane->Zat0() <= floorHeight)
|
||||||
{
|
{
|
||||||
|
@ -576,7 +576,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
rw_pic = nullptr;
|
rw_pic = nullptr;
|
||||||
if (rover->bottom.plane->Zat0() >= m3DFloor.sclipTop || passed)
|
if (rover->bottom.plane->Zat0() >= clipTop || passed)
|
||||||
{
|
{
|
||||||
if (last)
|
if (last)
|
||||||
{
|
{
|
||||||
|
@ -598,8 +598,8 @@ namespace swrenderer
|
||||||
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
||||||
|
|
||||||
// visible?
|
// visible?
|
||||||
if (fover->top.plane->Zat0() <= m3DFloor.sclipBottom) continue; // no
|
if (fover->top.plane->Zat0() <= clipBottom) continue; // no
|
||||||
if (fover->bottom.plane->Zat0() >= m3DFloor.sclipTop)
|
if (fover->bottom.plane->Zat0() >= clipTop)
|
||||||
{ // no, last possible
|
{ // no, last possible
|
||||||
fover = nullptr;
|
fover = nullptr;
|
||||||
break;
|
break;
|
||||||
|
@ -651,8 +651,8 @@ namespace swrenderer
|
||||||
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
||||||
|
|
||||||
// visible?
|
// visible?
|
||||||
if (fover->top.plane->Zat0() <= m3DFloor.sclipBottom) continue; // no
|
if (fover->top.plane->Zat0() <= clipBottom) continue; // no
|
||||||
if (fover->bottom.plane->Zat0() >= m3DFloor.sclipTop)
|
if (fover->bottom.plane->Zat0() >= clipTop)
|
||||||
{ // visible, last possible
|
{ // visible, last possible
|
||||||
fover = nullptr;
|
fover = nullptr;
|
||||||
break;
|
break;
|
||||||
|
@ -703,7 +703,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
||||||
{
|
{
|
||||||
if (m3DFloor.sclipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
|
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
|
||||||
{
|
{
|
||||||
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
||||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||||
|
@ -717,7 +717,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
||||||
{
|
{
|
||||||
if (m3DFloor.sclipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
|
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
|
||||||
{
|
{
|
||||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
||||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||||
|
@ -732,7 +732,7 @@ namespace swrenderer
|
||||||
|
|
||||||
if (rw_pic != DONT_DRAW)
|
if (rw_pic != DONT_DRAW)
|
||||||
{
|
{
|
||||||
RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade, basecolormap);
|
RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade, basecolormap, clipTop, clipBottom);
|
||||||
}
|
}
|
||||||
else rw_pic = nullptr;
|
else rw_pic = nullptr;
|
||||||
break;
|
break;
|
||||||
|
@ -749,7 +749,7 @@ namespace swrenderer
|
||||||
passed = 0;
|
passed = 0;
|
||||||
if (!(rover->flags & FF_RENDERSIDES) ||
|
if (!(rover->flags & FF_RENDERSIDES) ||
|
||||||
rover->top.plane->isSlope() || rover->bottom.plane->isSlope() ||
|
rover->top.plane->isSlope() || rover->bottom.plane->isSlope() ||
|
||||||
rover->bottom.plane->Zat0() >= m3DFloor.sclipTop ||
|
rover->bottom.plane->Zat0() >= clipTop ||
|
||||||
rover->top.plane->Zat0() <= floorHeight ||
|
rover->top.plane->Zat0() <= floorHeight ||
|
||||||
rover->bottom.plane->Zat0() >= ceilingHeight)
|
rover->bottom.plane->Zat0() >= ceilingHeight)
|
||||||
{
|
{
|
||||||
|
@ -763,7 +763,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rw_pic = nullptr;
|
rw_pic = nullptr;
|
||||||
if (rover->top.plane->Zat0() <= m3DFloor.sclipBottom || passed)
|
if (rover->top.plane->Zat0() <= clipBottom || passed)
|
||||||
{ // maybe wall from inside rendering?
|
{ // maybe wall from inside rendering?
|
||||||
fover = nullptr;
|
fover = nullptr;
|
||||||
for (j = 0; j < (int)frontsector->e->XFloor.ffloors.Size(); j++)
|
for (j = 0; j < (int)frontsector->e->XFloor.ffloors.Size(); j++)
|
||||||
|
@ -780,8 +780,8 @@ namespace swrenderer
|
||||||
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
||||||
|
|
||||||
// visible?
|
// visible?
|
||||||
if (fover->bottom.plane->Zat0() >= m3DFloor.sclipTop) continue; // no
|
if (fover->bottom.plane->Zat0() >= clipTop) continue; // no
|
||||||
if (fover->top.plane->Zat0() <= m3DFloor.sclipBottom)
|
if (fover->top.plane->Zat0() <= clipBottom)
|
||||||
{ // no, last possible
|
{ // no, last possible
|
||||||
fover = nullptr;
|
fover = nullptr;
|
||||||
break;
|
break;
|
||||||
|
@ -832,8 +832,8 @@ namespace swrenderer
|
||||||
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
|
||||||
|
|
||||||
// visible?
|
// visible?
|
||||||
if (fover->bottom.plane->Zat0() >= m3DFloor.sclipTop) continue; // no
|
if (fover->bottom.plane->Zat0() >= clipTop) continue; // no
|
||||||
if (fover->top.plane->Zat0() <= m3DFloor.sclipBottom)
|
if (fover->top.plane->Zat0() <= clipBottom)
|
||||||
{ // visible, last possible
|
{ // visible, last possible
|
||||||
fover = nullptr;
|
fover = nullptr;
|
||||||
break;
|
break;
|
||||||
|
@ -882,7 +882,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
for (j = backsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
||||||
{
|
{
|
||||||
if (m3DFloor.sclipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
|
if (clipTop <= backsector->e->XFloor.lightlist[j].plane.Zat0())
|
||||||
{
|
{
|
||||||
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
||||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||||
|
@ -896,7 +896,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
for (j = frontsector->e->XFloor.lightlist.Size() - 1; j >= 0; j--)
|
||||||
{
|
{
|
||||||
if (m3DFloor.sclipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
|
if (clipTop <= frontsector->e->XFloor.lightlist[j].plane.Zat0())
|
||||||
{
|
{
|
||||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
||||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||||
|
@ -911,7 +911,7 @@ namespace swrenderer
|
||||||
|
|
||||||
if (rw_pic != DONT_DRAW)
|
if (rw_pic != DONT_DRAW)
|
||||||
{
|
{
|
||||||
RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade, basecolormap);
|
RenderFakeWall(ds, x1, x2, fover ? fover : rover, wallshade, basecolormap, clipTop, clipBottom);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -952,7 +952,6 @@ namespace swrenderer
|
||||||
top = MAX(frontcz1, frontcz2);
|
top = MAX(frontcz1, frontcz2);
|
||||||
bot = MIN(frontfz1, frontfz2);
|
bot = MIN(frontfz1, frontfz2);
|
||||||
|
|
||||||
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
|
||||||
if (m3DFloor.clipTop)
|
if (m3DFloor.clipTop)
|
||||||
{
|
{
|
||||||
top = MIN(top, m3DFloor.sclipTop);
|
top = MIN(top, m3DFloor.sclipTop);
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace swrenderer
|
||||||
private:
|
private:
|
||||||
bool RenderWall(DrawSegment *ds, int x1, int x2, WallDrawerArgs &walldrawerargs, SpriteDrawerArgs &columndrawerargs, bool visible, FDynamicColormap *basecolormap, int wallshade);
|
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 ClipMidtex(int x1, int x2);
|
||||||
void RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap);
|
void RenderFakeWall(DrawSegment *ds, int x1, int x2, F3DFloor *rover, int wallshade, FDynamicColormap *basecolormap, double clipTop, double clipBottom);
|
||||||
void RenderFakeWallRange(DrawSegment *ds, int x1, int x2, int wallshade);
|
void RenderFakeWallRange(DrawSegment *ds, int x1, int x2, int wallshade);
|
||||||
void GetMaskedWallTopBottom(DrawSegment *ds, double &top, double &bot);
|
void GetMaskedWallTopBottom(DrawSegment *ds, double &top, double &bot);
|
||||||
|
|
||||||
|
|
|
@ -100,20 +100,22 @@ namespace swrenderer
|
||||||
CameraLight *cameraLight = CameraLight::Instance();
|
CameraLight *cameraLight = CameraLight::Instance();
|
||||||
if (!cameraLight->FixedColormap() && cameraLight->FixedLightLevel() < 0 && spr->sector->e && spr->sector->e->XFloor.lightlist.Size())
|
if (!cameraLight->FixedColormap() && cameraLight->FixedLightLevel() < 0 && spr->sector->e && spr->sector->e->XFloor.lightlist.Size())
|
||||||
{
|
{
|
||||||
if (!clip3DFloor.clipTop)
|
double clipTop;
|
||||||
{
|
if (clip3DFloor.clipTop)
|
||||||
clip3DFloor.sclipTop = spr->sector->ceilingplane.ZatPoint(thread->Viewport->viewpoint.Pos);
|
clipTop = clip3DFloor.clipTop;
|
||||||
}
|
else
|
||||||
|
clipTop = spr->sector->ceilingplane.ZatPoint(thread->Viewport->viewpoint.Pos);
|
||||||
|
|
||||||
sector_t *sec = nullptr;
|
sector_t *sec = nullptr;
|
||||||
FDynamicColormap *mybasecolormap = nullptr;
|
FDynamicColormap *mybasecolormap = nullptr;
|
||||||
for (int i = spr->sector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
|
for (int i = spr->sector->e->XFloor.lightlist.Size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (clip3DFloor.sclipTop <= spr->sector->e->XFloor.lightlist[i].plane.Zat0())
|
if (clipTop <= spr->sector->e->XFloor.lightlist[i].plane.Zat0())
|
||||||
{
|
{
|
||||||
rover = spr->sector->e->XFloor.lightlist[i].caster;
|
rover = spr->sector->e->XFloor.lightlist[i].caster;
|
||||||
if (rover)
|
if (rover)
|
||||||
{
|
{
|
||||||
if (rover->flags & FF_DOUBLESHADOW && clip3DFloor.sclipTop <= rover->bottom.plane->Zat0())
|
if (rover->flags & FF_DOUBLESHADOW && clipTop <= rover->bottom.plane->Zat0())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue