From 05ca52d693a068367e8fefa833a6b2a8e01a6aa3 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl <dpjudas@users.noreply.github.com> Date: Sat, 19 Aug 2017 00:53:41 +0200 Subject: [PATCH] - Fix texture coordinates for 3d floor walls --- src/polyrenderer/scene/poly_scene.cpp | 2 +- src/polyrenderer/scene/poly_wall.cpp | 12 ++++++------ src/polyrenderer/scene/poly_wall.h | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/polyrenderer/scene/poly_scene.cpp b/src/polyrenderer/scene/poly_scene.cpp index 1f61f1999..b37e2027a 100644 --- a/src/polyrenderer/scene/poly_scene.cpp +++ b/src/polyrenderer/scene/poly_scene.cpp @@ -339,7 +339,7 @@ void RenderPolyScene::RenderLine(subsector_t *sub, seg_t *line, sector_t *fronts } // 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++) { diff --git a/src/polyrenderer/scene/poly_wall.cpp b/src/polyrenderer/scene/poly_wall.cpp index af350418e..55fb940a9 100644 --- a/src/polyrenderer/scene/poly_wall.cpp +++ b/src/polyrenderer/scene/poly_wall.cpp @@ -89,6 +89,7 @@ bool RenderPolyWall::RenderLine(const TriMatrix &worldToClip, const PolyClipPlan wall.LineSeg = line; wall.Line = line->linedef; wall.Side = line->sidedef; + wall.LineSegLine = line->linedef; wall.Colormap = GetColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::walltop]); wall.Masked = false; wall.SubsectorDepth = subsectorDepth; @@ -188,11 +189,12 @@ void RenderPolyWall::Render3DFloorLine(const TriMatrix &worldToClip, const PolyC double frontfloorz1 = fakeFloor->bottom.plane->ZatPoint(line->v1); double frontceilz2 = fakeFloor->top.plane->ZatPoint(line->v2); double frontfloorz2 = fakeFloor->bottom.plane->ZatPoint(line->v2); - double topTexZ = frontsector->GetPlaneTexZ(sector_t::ceiling); - double bottomTexZ = frontsector->GetPlaneTexZ(sector_t::floor); + double topTexZ = fakeFloor->model->GetPlaneTexZ(sector_t::ceiling); + double bottomTexZ = fakeFloor->model->GetPlaneTexZ(sector_t::floor); RenderPolyWall wall; wall.LineSeg = line; + wall.LineSegLine = line->linedef; wall.Line = fakeFloor->master; wall.Side = fakeFloor->master->sidedef[0]; 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.TopTexZ = topTexZ; wall.BottomTexZ = bottomTexZ; - wall.UnpeggedCeil1 = frontceilz1; - wall.UnpeggedCeil2 = frontceilz2; wall.Texpart = side_t::mid; wall.Render(worldToClip, clipPlane, cull); } @@ -249,7 +249,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const PolyClipPlane &c 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 texcoordsVRght(tex, Line, Side, Texpart, ceil2, floor2, UnpeggedCeil2, TopTexZ, BottomTexZ); 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 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(); lineu2 *= tex->Scale.X / tex->GetWidth(); diff --git a/src/polyrenderer/scene/poly_wall.h b/src/polyrenderer/scene/poly_wall.h index 608fe241d..49be17543 100644 --- a/src/polyrenderer/scene/poly_wall.h +++ b/src/polyrenderer/scene/poly_wall.h @@ -45,6 +45,7 @@ public: double floor2 = 0.0; const seg_t *LineSeg = nullptr; + const line_t *LineSegLine = nullptr; const line_t *Line = nullptr; const side_t *Side = nullptr; side_t::ETexpart Texpart = side_t::mid; @@ -70,7 +71,7 @@ private: class PolyWallTextureCoordsU { 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; };