- Fix texture coordinates for 3d floor walls

This commit is contained in:
Magnus Norddahl 2017-08-19 00:53:41 +02:00
parent b8ab626609
commit 05ca52d693
3 changed files with 9 additions and 8 deletions

View file

@ -339,7 +339,7 @@ void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *fronts
} }
// Render 3D floor sides // Render 3D floor sides
if (line->backsector && frontsector->e && line->backsector->e->XFloor.ffloors.Size()) if (line->sidedef && line->backsector && line->backsector->e && line->backsector->e->XFloor.ffloors.Size())
{ {
for (unsigned int i = 0; i < line->backsector->e->XFloor.ffloors.Size(); i++) for (unsigned int i = 0; i < line->backsector->e->XFloor.ffloors.Size(); i++)
{ {

View file

@ -89,6 +89,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const PolyClipPlan
wall.LineSeg = line; wall.LineSeg = line;
wall.Line = line->linedef; wall.Line = line->linedef;
wall.Side = line->sidedef; wall.Side = line->sidedef;
wall.LineSegLine = line->linedef;
wall.Colormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]); wall.Colormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
wall.Masked = false; wall.Masked = false;
wall.SubsectorDepth = subsectorDepth; wall.SubsectorDepth = subsectorDepth;
@ -188,11 +189,12 @@ void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const PolyC
double frontfloorz1 = fakeFloor->bottom.plane->ZatPoint(line->v1); double frontfloorz1 = fakeFloor->bottom.plane->ZatPoint(line->v1);
double frontceilz2 = fakeFloor->top.plane->ZatPoint(line->v2); double frontceilz2 = fakeFloor->top.plane->ZatPoint(line->v2);
double frontfloorz2 = fakeFloor->bottom.plane->ZatPoint(line->v2); double frontfloorz2 = fakeFloor->bottom.plane->ZatPoint(line->v2);
double topTexZ = frontsector->GetPlaneTexZ(sector_t::ceiling); double topTexZ = fakeFloor->model->GetPlaneTexZ(sector_t::ceiling);
double bottomTexZ = frontsector->GetPlaneTexZ(sector_t::floor); double bottomTexZ = fakeFloor->model->GetPlaneTexZ(sector_t::floor);
RenderPolyWall wall; RenderPolyWall wall;
wall.LineSeg = line; wall.LineSeg = line;
wall.LineSegLine = line->linedef;
wall.Line = fakeFloor->master; wall.Line = fakeFloor->master;
wall.Side = fakeFloor->master->sidedef[0]; wall.Side = fakeFloor->master->sidedef[0];
wall.Colormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]); wall.Colormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]);
@ -202,8 +204,6 @@ void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const PolyC
wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2); wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2);
wall.TopTexZ = topTexZ; wall.TopTexZ = topTexZ;
wall.BottomTexZ = bottomTexZ; wall.BottomTexZ = bottomTexZ;
wall.UnpeggedCeil1 = frontceilz1;
wall.UnpeggedCeil2 = frontceilz2;
wall.Texpart = side_t::mid; wall.Texpart = side_t::mid;
wall.Render(worldToClip, clipPlane, cull); wall.Render(worldToClip, clipPlane, cull);
} }
@ -249,7 +249,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c
if (tex) if (tex)
{ {
PolyWallTextureCoordsU texcoordsU(tex, LineSeg, Line, Side, Texpart); PolyWallTextureCoordsU texcoordsU(tex, LineSeg, LineSegLine, Side, Texpart);
PolyWallTextureCoordsV texcoordsVLeft(tex, Line, Side, Texpart, ceil1, floor1, UnpeggedCeil1, TopTexZ, BottomTexZ); PolyWallTextureCoordsV texcoordsVLeft(tex, Line, Side, Texpart, ceil1, floor1, UnpeggedCeil1, TopTexZ, BottomTexZ);
PolyWallTextureCoordsV texcoordsVRght(tex, Line, Side, Texpart, ceil2, floor2, UnpeggedCeil2, TopTexZ, BottomTexZ); PolyWallTextureCoordsV texcoordsVRght(tex, Line, Side, Texpart, ceil2, floor2, UnpeggedCeil2, TopTexZ, BottomTexZ);
vertices[0].u = (float)texcoordsU.u1; vertices[0].u = (float)texcoordsU.u1;
@ -401,7 +401,7 @@ PolyWallTextureCoordsU::PolyWallTextureCoordsU(FTexture *tex, const seg_t *lines
{ {
// Calculate the U texture coordinate for the line // Calculate the U texture coordinate for the line
double lineu1 = side->GetTextureXOffset(texpart); double lineu1 = side->GetTextureXOffset(texpart);
double lineu2 = side->GetTextureXOffset(texpart) + side->TexelLength * side->GetTextureXScale(texpart); double lineu2 = side->GetTextureXOffset(texpart) + line->sidedef[0]->TexelLength * side->GetTextureXScale(texpart);
lineu1 *= tex->Scale.X / tex->GetWidth(); lineu1 *= tex->Scale.X / tex->GetWidth();
lineu2 *= tex->Scale.X / tex->GetWidth(); lineu2 *= tex->Scale.X / tex->GetWidth();

View file

@ -45,6 +45,7 @@ public:
double floor2 = 0.0; double floor2 = 0.0;
const seg_t *LineSeg = nullptr; const seg_t *LineSeg = nullptr;
const line_t *LineSegLine = nullptr;
const line_t *Line = nullptr; const line_t *Line = nullptr;
const side_t *Side = nullptr; const side_t *Side = nullptr;
side_t::ETexpart Texpart = side_t::mid; side_t::ETexpart Texpart = side_t::mid;
@ -70,7 +71,7 @@ private:
class PolyWallTextureCoordsU class PolyWallTextureCoordsU
{ {
public: public:
PolyWallTextureCoordsU(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart texpart); PolyWallTextureCoordsU(FTexture *tex, const seg_t *lineseg, const line_t *linesegline, const side_t *side, side_t::ETexpart texpart);
double u1, u2; double u1, u2;
}; };